compiler-flags

Optimization and flags for making a static library with g++

旧城冷巷雨未停 提交于 2019-12-02 14:10:38
I am just starting with g++ compiler on Linux and got some questions on the compiler flags. Here are they Optimizations I read about optimization flags -O1 , -O2 and -O3 in the g++ manual page. I didn't understood when to use these flags. Usually what optimization level do you use? The g++ manual says the following for -O2 . Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify -O2. As compared to -O, this option increases both compilation time and the

Is there any way to override the -fvisibility=hidden at link time?

£可爱£侵袭症+ 提交于 2019-12-02 12:49:07
We are using an third party static library, let say A.a for android development. We link it as shared library and it works fine in the one App, but when use B.so to build another C.so , some symbols in A.a cannot find. We have already use -Wl,--export-dynamic and -Wl,--whole-archive to build B.so . We have using nm to check those symbols, it exist but list as “t” instead of “T” ,which means it is local symbols instead of external. Seams the A.a are build with -fvisibility=hidden after som investigation. But because some reason it is hard for us to got an new build library immediately, so we

Compiler flags in Eclipse

心不动则不痛 提交于 2019-12-02 09:44:27
My build requires that I issue the following commands: $ g++ sniff.cpp -o sniff -lcrafter However, in my Eclipse build, all the complier gets is: g++ -o "sniffer_crafter" ./src/sniffer_crafter.o After getting these commands it complains that I have an undefined reference to the library Crafter. How can I resolve this linking issue using Eclipse? I have seen others answers to similar questions, but they don't seem to address Eclipse's current layout. I'm using the most recent edition of Eclipse Kepler. Include libraries:- right click on the project --> Goto Properties then goto --> C/C++ Build

Is it realistic to use -O3 or -Ofast to compile your benchmark code or will it remove code?

冷暖自知 提交于 2019-12-01 20:56:27
When compiling the benchmark code below with -O3 I was impressed by the difference it made in latency so i began to wonder whether the compiler is not "cheating" by removing code somehow. Is there a way to check for that? Am I safe to benchmark with -O3 ? Is it realistic to expect 15x gains in speed? Results without -O3 : Average: 239 nanos Min: 230 nanos (9 million iterations) Results with -O3 : Average: 14 nanos, Min: 12 nanos (9 million iterations) int iterations = stoi(argv[1]); int load = stoi(argv[2]); long long x = 0; for(int i = 0; i < iterations; i++) { long start = get_nano_ts(); //

C++ -malign-double compiler flag

心不动则不痛 提交于 2019-12-01 20:52:13
问题 I need some help on compiler flags in c++. I'm using a library that is a port to linux from windows, that has to be compiled with the -malign-double flag, "for Win32 compatibility". It's my understanding that this mean I absolutely have to compile my own code with this flag as well? How about other .so shared libraries, do they have be recompiled with this flag as well? If so, is there any way around this? I'm a linux newbie (and c++), so even though I tried to recompile all the libraries I'm

Set Java compiler compliance level

爱⌒轻易说出口 提交于 2019-12-01 03:16:16
I need to compile a Java program on the command line, and I am trying to set the compiler level to a lower one (1.6). I tried like this but it didn't work: javac -1.6 Hello.java Use -source and -target options: javac -target 1.6 -source 1.6 Hello.java Nayuki Use: javac -source 1.6 -target 1.6 Hello.java This information comes from running javac -help : Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output

Position of compiler flag -l

江枫思渺然 提交于 2019-11-30 18:57:57
问题 I'm currently learning OpenCL. Now, when I want to compile my program, I get an error with this command: g++ -Wall -l OpenCL main.cpp -o main The errors are mostly undefined references, because the library is not linked, I think (nevertheless I will post the error code at the end). But with this command everything works fine: g++ -Wall main.cpp -o main -l OpenCL So my question is, what do I have to do, to use the -l Flag in front of the command? (The Background is: I want to use Netbeans to

Make: Override a flag

可紊 提交于 2019-11-30 15:45:59
I was a little confused with the responses to Quick way to override -Werror flag? So I ask my specific question here. I have multiple Makefiles working together and CFLAGS has been set along the way to (-Werror -Wall .. and many others) But in one of the Makefiles, I wish that the errors not be treated as warnings and so I would like to remove -Werror flag. What would be the best way to achieve this, so that only for this Makefile, -Werror flag is removed and for the others normal execution takes place? Thanks, Sunny Simpler way It looks like you can invoke gcc -c ... -Werror ... -Wno-error ..

Xcode Project-Wide compiler flag

北战南征 提交于 2019-11-30 13:56:05
With Xcode 4.2 and the LLVM compiler, when compiling for ARMv6 there are some very weird bugs in the generated application (such as "width" property of CGSize returning the "height" instead). To fix this, I found I must set the compiler flag -mno-thumb. I know how to set compiler flags on a file-by-file basis, but is there a way to set a compiler flag for the entire project? You can set project wide compiler flags in the project settings under the "Language" section of the "Build Settings" tab. 来源: https://stackoverflow.com/questions/7932834/xcode-project-wide-compiler-flag

Why is /Wp64 deprecated?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 08:06:27
问题 Why is the /Wp64 flag in Visual C++ deprecated? cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release 回答1: I think that /Wp64 is deprecated mainly because compiling for a 64-bit target will catch the kinds of errors it was designed to catch (/Wp64 is only valid in 32-bit compiles). The option was added back when 64-bit targets were emerging to help people migrate their programs to 64-bit and help detect code that wasn't '64-bit clean'.