Thursday 15 July 2010

c++ - Qt Creator 3.2.2 / Mac OSX 10.9.3 Undefined symbol in Qt Creator, OK in command line -



c++ - Qt Creator 3.2.2 / Mac OSX 10.9.3 Undefined symbol in Qt Creator, OK in command line -

i'm having issue linker fails due undefined symbol while works great in command line. hope guys can help me figure out.

costesmanager_gui.pro

#------------------------------------------------- # # project created qtcreator 2014-10-22t14:45:23 # #------------------------------------------------- qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = costesmanager_gui template = app sources += main.cpp\ mainwindow.cpp headers += mainwindow.h forms += mainwindow.ui includepath += /users/noe/boost_1_56_0 libs += -l/users/noe/costesmanager/gui/costesmanager_gui/lib -lyaml-cpp includepath += /users/noe/costesmanager/gui/costesmanager_gui/yaml-cpp/include

output of command tree :

$ tree . ├── costesmanager_gui.pro ├── costesmanager_gui.pro.user ├── lib │   └── libyaml-cpp.a ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── test.cpp └── yaml-cpp ... ├── include │   └── yaml-cpp ... │   └── yaml.h ...

compiler output :

undefined symbols architecture x86_64: "yaml::loadfile(std::string const&)", referenced from: _main in main.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) make: *** [costesmanager_gui.app/contents/macos/costesmanager_gui] error 1 15:50:30: le processus "/usr/bin/make" s'est terminé avec le code 2. erreur lors de la compilation/déploiement du projet costesmanager_gui (kit : desktop qt 5.3 clang 64bit) when executing step "make"

my main.cpp file consists of basic yaml::loadfile("foo.bar") , trying display it.

i have tried create test.cpp calling yaml::loadfile(), compile 2 next commands (qt produces same + including stuff, can paste well) :

$ clang++ -c -i/users/noe/costesmanager/gui/costesmanager_gui/yaml-cpp/include -i /users/noe/boost_1_56_0 -o test.o test.cpp $ clang++ test.o -o test -l/users/noe/costesmanager/gui/costesmanager_gui/lib/ -lyaml-cpp

... , works.

i don't know missing. give thanks lot !

edit : if have suggestions clean tree, thrilled. don't know standard way organise this.

okay solution easy tricky spot (crazy hunt).

since there 2 c++ standard libraries in osx (see here), had tell compiler utilize libc++.

therefore added

qmake_cxxflags = -stdlib=libc++ libs += -stdlib=libc++

to .pro file , works correctly !

still don't know why on command line don't have but... if has clue ?

have day everyone.

c++ osx qt linker undefined-symbol

No comments:

Post a Comment