Michael Wild <[email protected]> writes: > On 23. Dec, 2009, at 9:56 , Water Lin wrote: > >> Michael Wild <[email protected]> writes: >> >>> On 23. Dec, 2009, at 9:22 , Water Lin wrote: >>> >>>> >>>> I am trying to use the "-03" option to gcc. But after I use >>>> -------------------- >>>> add_definitions(-03) >>>> -------------------- >>>> >>>> in CMakeLists.txt file and generate the Makefile, I make the project and >>>> gcc provides me a info: >>>> ----------- >>>> c++: unrecognized option '-03' >>>> ----------- >>>> >>>> How can I add "-03" option by CMakeLists.txt? >>>> >>>> Thanks >>>> >>>> Water Lin >>> >>> That's because the options is not called -03 ("dash zero three") but -O3 >>> ("dash big-ooh three"). >>> >>> And you shouldn't do that anyways. Rather set the CMAKE_BUILD_TYPE option >>> to "Release" in your cache (NOT the CMakeLists.txt file). E.g. if you're >>> using the command line: >>> >>> cmake -DCMAKE_BUILD_TYPE=Release /path/to/source >> >> Do you mean that if I set -DCMAKE_BUILD_TYPE=Release, I will get the -O3 >> option? >> >> I tried it, it seems work that way. But while I run my code, it will get >> a segmentation fault. >> >> Is this the correct way? >> >> Thanks >> >> Water Lin > > Well, the segmentation fault is almost surely a programming error and nothing > that CMake (close to impossible) or your compiler (very unlikely, but > possible) caused. Does the program run if you don't use -O3? That usually > indicates that you are messing with your memory (i.e. writing/reading past > array boundaries, referring to deallocated objects/variables, etc.). On Linux > you can use the tool called valgrind to find such errors. > > Michael
Thanks a lot for you detail descriptions. I think there is some potential error in my program. I will check it. Thanks Water Lin > > -- Water Lin's notes and pencils: http://en.waterlin.org Email: [email protected] __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
