redhat:netbeans:g++:应用于链接器的编译器选项

redhat: netbeans: g++: compiler options applied to linker

我在 RedHat 下使用 NetBeans。我有几个打开的项目,它们结合在一起使命令行可执行和共享对象 "plugin"。混合中还有两个静态库。这一切都很好。

我刚刚注意到,当我 "clean and build" 编译器选项的可执行文件和共享对象也在 linker 行上表示时。啦啦:

g++ -O2 -Wall -c -fmessage-length=0   -c -g -Werror -DDEBUG -DDEBUG_2 -I/usr/include -I/usr/include/c++/4.4.7/x86_64-redhat-linux -I/usr/include/c++/4.4.7 -I../ITGUtilities -MMD -MP -MF "build/Debug/GNU-Linux-x86/LocalCache.o.d" -o build/Debug/GNU-Linux-x86/LocalCache.o LocalCache.cpp

然后在编译行的后面(为简洁起见进行了编辑):

g++ -O2 -Wall -c -fmessage-length=0 -fPIC    -o dist/Debug/GNU-Linux-x86/pam_plugin.so build/Debug/GNU-Linux-x86/pam_plugin.o -L... -lpam -l... -shared -fPIC
g++: build/Debug/GNU-Linux-x86/pam_plugin.o: linker input file unused because linking not done

我认为我有一组相当通用的项目配置。我确实设置了 -O2 -Wall -c -fmessage-length=0 编译器选项,但没有为 linker 提供任何选项,除了 NetBeans 应用的任何默认值。

对于可执行文件和插件项目,我可以转到 Properties > Linker > Additional Options 并展开 [...] 以查看 NB 认为它适用的内容。这不显示编译选项,但进行实际构建时会应用它们。

它没有执行 link 步骤,我假设这是因为编译器选项。这很奇怪。

想法?

不要将 -c 选项添加到编译器选项,它表示不对 运行 链接器。反正编译的时候会根据需要加上。