Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:11:55+00:00 2026-05-24T17:11:55+00:00

What I have: my code (simple main.cpp), headers of the 3rd party lib (EnvVar

  • 0

What I have: my code (simple main.cpp), headers of the 3rd party lib (EnvVar TPLIB_INCLUDE), binary lib (several .a files in TPLIB_BINARY_PATH) and the following CMakeLists.txt:

# current source directory: CMAKE_CURRENT_SOURCE_DIR
# current binary directory: CMAKE_CURRENT_BINARY_DIR

# require 2.6 to get support for the simple IF construct
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)

PROJECT( simpleapp)
SET( PROGNAME simpleapp )

SET( CMAKE_COLOR_MAKEFILE ON )
SET( CMAKE_VERBOSE_MAKEFILE ON )
SET( CMAKE_INCLUDE_CURRENT_DIR TRUE )

# the actual .cpp files go here
SET(project_SOURCES
    main.cpp
)

# add here all files that need processing by Qt's MOC if there are any
set(project_MOC_SOURCES
    # files would go here
)

# add here all files that will be processed by Qt's UIC
set(project_UIS
    # all .ui files would go here
)

# additional Qt resources go here
set(project_RCCS
    # all .qrc files would go here
)

# setup Qt
FIND_PACKAGE(Qt4 REQUIRED)

INCLUDE(${QT_USE_FILE})

QT4_WRAP_CPP(test_MOCS ${project_MOC_SOURCES})
QT4_WRAP_UI(test_UIS_H ${project_UIS})
QT4_WRAP_CPP(test_MOC_UI ${project_UIS_H})
QT4_ADD_RESOURCES(test_RCC_SRCS ${project_RCCS})

include_directories( ${CMAKE_BINARY_DIR} $ENV{TPLIB_INCLUDE})

ADD_EXECUTABLE( ${PROGNAME} ${project_SOURCES} ${test_MOCS} ${test_RCC_SRCS} ${test_MOC_UI} )

link_directories($ENV{TPLIB_BINARY_PATH})

TARGET_LINK_LIBRARIES(${PROGNAME} ${QT_LIBRARIES} lib_misc lib_tools)

makeing the project creating the main.cpp.o works as usual. Thus CMake found the third party headers. When it comes to link ld complains cannot find -llib_misc and -llib_tools.
Removing the “link_directories” line or specifiingy the libs absolute name leads to “No rule to make target /path/to/lib_misc.a”

So how to tell CMake to use these libs for linking only?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:12:01+00:00Added an answer on May 24, 2026 at 5:12 pm

    link_directories($ENV{TPLIB_BINARY_PATH}) should be placed before ADD_EXECUTABLE.

    From the official documents of CMake, there are notes on link_directories:

    The command will apply only to targets created after it is called.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the very simple following code: main.cpp #include ui_library_browser.h #include <QtGui/QApplication> #include StartWindow.h
Several lines of code are worth a thousand words: I have three simple files:
Several lines of code are worth a thousand words: I have three simple files:
I have to code a simple control in .Net that draws geometry that looks
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have a simple code byte[] buffer = Encoding.UTF8.GetBytes(abracadabra); MemoryStream ms = new MemoryStream();
I have a simple code fragment in JS working with prototype inheritance. function object(o)
There is probably is simple fix for this but I currently have code similar
I am a total beginner in JS/XML. I have this simple code that needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.