简体   繁体   English

代码中的gcc std选项和链接器选项

[英]gcc std option and linker option in code

I switch between so many projects and IDEs a lot. 我经常在很多项目和IDE之间切换。 They run each project with default options of IDE. 他们使用IDE的默认选项运行每个项目。 For example 例如

g++ test.cpp

I know make file can solve the problem. 我知道make file可以解决问题。 But it is not IDE friendly way. 但这不是IDE友好的方式。 I am thinking if there is any way to impose option 我在想是否有办法施加选择权

-std=c++11

In the code rather than in calling g++. 在代码中而不是在调用g ++中。

The same problem with linker. 链接器的相同问题。 I want to tell the linker in the code that I want to link to armadillo library 我想告诉代码中的链接器我想链接到犰狳库

-larmadillo

Maybe setting a prepossessing command could solve the problem. 也许设置预设命令可以解决该问题。 Is there any solution for it? 它有什么解决方案吗?

Have you tried CMake ? 您尝试过CMake吗? With this you can create compiler and IDE independent makefiles and then generate the makefiles/project files for the environment of your choise. 这样,您可以创建独立于编译器和IDE的makefile,然后为您所选择的环境生成makefiles / project文件。 You can freely script it so you can set certin swithces for gcc and other for vc++ or clang. 您可以自由编写脚本,以便可以为gcc和vc ++或clang设置certin开关。

You can also use it if you want to create different build configurations. 如果要创建其他构建配置,也可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM