compiler flags with cross-compiled cmake linux project

Sysprogs forums Forums VisualGDB compiler flags with cross-compiled cmake linux project

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27645
    micha
    Participant

    I’m trying to add the flag “-pthread” to a cr0ss-compiled cmake project.

    I’m using v5.5 preview 4.

    Searching gave me this thread https://sysprogs.com/w/forums/topic/compiler-flags/ from 2 years ago and I have the feeling the menu’s have changed in the meantime as I cannot find the CFLAGS option being talked about in the thread.

    When I add it to either the “CMake command” or the “Extra CMake configuration variables” I get the following build message:

    “CMake Warning:
    Manually-specified variables were not used by the project:

    -pthread
    CMAKE_COLOR_MAKEFILE”

    Any help would be appreciated.

    (Also, what is this CMAKE_COLOR_MAKEFILE?)

    #27662
    micha
    Participant

    Fixed it some other way, for anyone else looking for this:

    As pthread is a library it should be mentioned in the target link libraries.

    In CMakeLists.txt edit the target_link_libraries(<your_project_name> “${LIBRARIES_FROM_REFERENCES}” pthread) < add the link here. Or if you want to do it via one of the many menu’s, it’s not in the VisualGDB project properties (or at least I couldn’t find it there). Go to the actual project properties, which is the 3rd from the top if you start a new one, right below the visualGDB project. Right click > project properties, then Linker > General > Additional inputs, here’s the previously mentioned “${LIBRARIES_FROM_REFERENCES}, expand it with a semicolon and then the library, like so: ${LIBRARIES_FROM_REFERENCES};pthread

    If there’s a more visualGDB-ish method please tell, I like to keep al my settings in one menu 🙂

    #27673
    support
    Keymaster

    Good to know it works. BTW, we have a detailed tutorial showing the necessary steps here: https://visualgdb.com/tutorials/linux/cmake/target_link_libraries/

    Please also feel free to try VisualGDB 5.5 Preview 4. It can automatically troubleshoot the “undefined reference” errors and suggest the necessary configuration changes.

    #27674
    micha
    Participant

    Thank you very much for your response.

    In fact I am on 5.5 preview 4. The first library (which needed the pthread) did actually automatically get added, however -pthread did not. Might this have anything to do with the fact that clang doesn’t automatically analyze the libraries added for errors?

    Once again the tutorial is very good! It probably went wrong in my head for looking to add compiler flags, which I thought would be the way to go, while in fact it was a linker thing. This would have made me find the mentioned tutorial.

    #27714
    support
    Keymaster

    The automatic library discovery is indeed not recursive, so if the added library depends on pthread, VisualGDB would only suggest adding pthread when you build the project again (and the build fails due to missing pthread functions).

    There also might have been a confusion between pthread and the asan library that provides similar functions, but is intended to work as a diagnostic layer on top of pthread. We have updated VisualGDB internally to hide the confusing asan/lsan libraries when searching for pthread symbols and only suggest the pthread library itself. Until we release the next preview build with this fix, please make sure you select the pthread library when VisualGDB suggests several libraries resolving pthread symbols.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.