openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.98k stars 2.55k forks source link

Qt Creator - problem compile linux (Arch / Ubuntu) #7021

Open trigop opened 2 years ago

trigop commented 2 years ago

I'm using the latest 'nightly' version and I've tested it on Arch and Ubuntu. I'm using Qt Creator 7 (I've tested it on different previous versions, even on version 4).

I have the same problem. When I use QT to compile it crashes but it doesn't happen in the console. When you include a library (any one) it always crashes: error: undefined reference to XXXX

Any help ?

ludiccc commented 2 years ago

I'm having the same issue. It seems like Qt Creator is having a problem with boost::filesystem::path...

/home/XXXXXX/dev/openFrameworks/addons/ofxXmlSettings/src/ofxXmlSettings.cpp:76: error: undefined reference to 'ofToDataPath[abi:cxx11](boost::filesystem::path const&, bool)' The same happens with a lot of other functions with similar calls.

ludiccc commented 2 years ago

Perhaps this gives somebody a clue about this: if I do something like this:

ofImage img; string path="myImage.jpg"; img.load(path);

I get the 'undefined reference to XXXX' error. But if I use the depecrated function .loadImage(path) instead, it works fine. I still have problems with other functions in addons who are working fine in osx and window$.

ludiccc commented 2 years ago

Just to clarify. I started an empty project from Qt Creator, with this code:

//--------------------------------------------------------------
void ofApp::setup(){
    img.load("mappingHelperImage.png");
}

//--------------------------------------------------------------
void ofApp::draw(){
    img.draw(0,0);
}

The compiler gave me this message:

/XXXX/test2/src/ofApp.cpp:5: error: undefined reference to 'ofImage_<unsigned char>::load(boost::filesystem::path const&, ofImageLoadSettings const&)'

ludiccc commented 2 years ago

Solved!

Adding this to the .qbs file solves the problem:

of.cxxFlags: ["-std=c++17"] // flags passed to the c++ compiler

@trigop , can you confirm if this helps?

ioadeer commented 1 year ago

of.cxxFlags: ["-std=c++17"] // flags passed to the c++ compiler

I was having the same issue on archlinux. Adding the flag solved the issue. Thanks.