Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can I create a so file for CMAKE Project, using QT?
Forum Updated to NodeBB v4.3 + New Features

Can I create a so file for CMAKE Project, using QT?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 492 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manykim
    wrote on last edited by
    #1

    using QT 5.6.3 version

    NewProject -> C++Library -> Shared Library

    made a project for so file and added a simple working function.

    I think i followed the basic form of shared library project.

    and built it, bring it to my CMAKE Project, added like below

    INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)

    find_library(
    libmy
    NAMES libmy_hello.so
    HINTS ./lib
    REQUIRED
    )
    target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})

    undefined reference to 'simple function' error occured.

    I do not reckon where i did wrong...

    any answer would be appriciated

    jsulmJ JoeCFDJ C 3 Replies Last reply
    0
    • M manykim

      using QT 5.6.3 version

      NewProject -> C++Library -> Shared Library

      made a project for so file and added a simple working function.

      I think i followed the basic form of shared library project.

      and built it, bring it to my CMAKE Project, added like below

      INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)

      find_library(
      libmy
      NAMES libmy_hello.so
      HINTS ./lib
      REQUIRED
      )
      target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})

      undefined reference to 'simple function' error occured.

      I do not reckon where i did wrong...

      any answer would be appriciated

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @manykim said in Can I create a so file for CMAKE Project, using QT?:

      undefined reference to 'simple function' error occured.

      Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 2 Replies Last reply
      0
      • jsulmJ jsulm

        @manykim said in Can I create a so file for CMAKE Project, using QT?:

        undefined reference to 'simple function' error occured.

        Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.

        M Offline
        M Offline
        manykim
        wrote on last edited by manykim
        #3

        @jsulm sir please tell me more, I think, because i cannot find any special error in CMAKE project, link was done correctly... then how can I export my function? i put the macro for "Q_DECL_EXPORT" before function name in header file. was it enough? sorry for my bad language

        jsulmJ 1 Reply Last reply
        0
        • jsulmJ jsulm

          @manykim said in Can I create a so file for CMAKE Project, using QT?:

          undefined reference to 'simple function' error occured.

          Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.

          M Offline
          M Offline
          manykim
          wrote on last edited by
          #4

          @jsulm I checked that in my qt Project the library works fine so I think export is ok... what would be my problem sir?

          1 Reply Last reply
          0
          • M manykim

            @jsulm sir please tell me more, I think, because i cannot find any special error in CMAKE project, link was done correctly... then how can I export my function? i put the macro for "Q_DECL_EXPORT" before function name in header file. was it enough? sorry for my bad language

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @manykim said in Can I create a so file for CMAKE Project, using QT?:

            link was done correctly

            How can it be correct if you get "undefined reference" linker error?!

            Regarding exporting symbols in libraries: please read https://doc.qt.io/qt-6/sharedlibrary.html

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply
            2
            • M manykim

              using QT 5.6.3 version

              NewProject -> C++Library -> Shared Library

              made a project for so file and added a simple working function.

              I think i followed the basic form of shared library project.

              and built it, bring it to my CMAKE Project, added like below

              INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)

              find_library(
              libmy
              NAMES libmy_hello.so
              HINTS ./lib
              REQUIRED
              )
              target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})

              undefined reference to 'simple function' error occured.

              I do not reckon where i did wrong...

              any answer would be appriciated

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by
              #6

              @manykim is this on Linux or Windows?

              M 1 Reply Last reply
              0
              • jsulmJ jsulm

                @manykim said in Can I create a so file for CMAKE Project, using QT?:

                link was done correctly

                How can it be correct if you get "undefined reference" linker error?!

                Regarding exporting symbols in libraries: please read https://doc.qt.io/qt-6/sharedlibrary.html

                M Offline
                M Offline
                manykim
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @manykim is this on Linux or Windows?

                  M Offline
                  M Offline
                  manykim
                  wrote on last edited by
                  #8

                  @JoeCFD Linux, Ubuntu !! sir

                  1 Reply Last reply
                  0
                  • M manykim

                    using QT 5.6.3 version

                    NewProject -> C++Library -> Shared Library

                    made a project for so file and added a simple working function.

                    I think i followed the basic form of shared library project.

                    and built it, bring it to my CMAKE Project, added like below

                    INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)

                    find_library(
                    libmy
                    NAMES libmy_hello.so
                    HINTS ./lib
                    REQUIRED
                    )
                    target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})

                    undefined reference to 'simple function' error occured.

                    I do not reckon where i did wrong...

                    any answer would be appriciated

                    C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by
                    #9

                    @manykim said in Can I create a so file for CMAKE Project, using QT?:

                    I do not reckon where i did wrong...

                    Did the linker even find your my_hello library?

                    Post the link related commands and output executed by the Makefile that CMake generated for you.

                    make VERBOSE=1
                    
                    1 Reply Last reply
                    0
                    • M manykim has marked this topic as solved on

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved