"library' settings and undefined reference

Sysprogs forums Forums VisualGDB "library' settings and undefined reference

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #25093
    teyk
    Participant

    Good morning,

    I use VisualGDB with cmake to cross compile my code on a raspbian and I’m trying to connect to my SQLite database but I have an undefined reference to sqlite and in my research I found this post: https://sysprogs.com/w/forums/topic/include-mysqlmysql-h-errorundefined-reference-to/

    Now my new found problem is, where do I find this “library” settings, until now I found 4 people saying they found it useful to their problem but I cant find this “library” setting.
    I’ve tried to go in the CMakeLists.txt to input the sqlite3 lib but only get additional errors.

    Sorry for the (surely) dumb and amateur question but I’ve been stuck for the last 4 hours.

    #25095
    support
    Keymaster

    Hi,

    If you are using an advanced CMake project, please locate your executable (console icon) in Solution Explorer, right-click on it and select “Properties”. Then add the “;-l<library name>” (e.g. -lmysql) to the Linker->General->Linked Libraries field.

    #25096
    teyk
    Participant

    I don’t know if I put it correctly because it does not work so I’m replying with this screenshot. Sorry for the trouble

    Attachments:
    You must be logged in to view attached files.
    #25098
    support
    Keymaster

    Please try checking the SQLite documentation for the exact name of the library file (e.g. libsqlite.a or libsqlite.so). Then use the “-l<name without extension and lib prefix>” syntax. Please do not use the ${} syntax, as it implies expanding a non-existent CMake variable.

    You can read more about the linker input format and library names on this page: http://visualgdb.com/support/linkerinputs/

    #25099
    teyk
    Participant

    Thank you! I will try it ou tuesday and inform you if it works!

    #25124
    teyk
    Participant

    The library works when I use the ${} syntax and not with “;-l<library name>”

    #25143
    support
    Keymaster

    Most likely, you have used another statement before that would define the libsqlite3-dev variable.

    We have just published a tutorial explaining different uses of the target_link_libraries statement in detail: https://visualgdb.com/tutorials/linux/cmake/target_link_libraries/

    Feel free to give it a try – it explains the inner workings of the CMake library logic in detail.

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