Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linking 3rd party libraries

Tags:

cmake

I have created a simple application that works ok. However, now I need to link with some libraries in the following directory.

/opt/norton/lib

In my make file I have the following with works, but I need to use cmake

LIBS_PATH = -L/opt/norton/lib
INC_PATH = -I/opt/norton/inc

LIBS = -lntctrl

In my CMakeList.txt I have this but doesn't work I keep gettng the following error:

undefined reference to `nt_init'

This is my CMakeList.txt

# Includes files
INCLUDE_DIRECTORIES(/opt/norton/inc)

# Link libraries
LINK_DIRECTORIES(/opt/norton/lib)

# Add the library that is used by nt_init
TARGET_LINK_LIBRARIES(-lntctrl)

ADD_LIBRARY(application initialize_nw) 

Many thanks for any advice,

like image 361
ant2009 Avatar asked Oct 28 '09 08:10

ant2009


People also ask

Is it good to use third party libraries?

The most important benefit of using third-party libraries is that it saves you time as you do not need to develop the functionality that the library provides. Instead, you can focus on the core business logic of your app: the features that really matter.

What is meant by third party library?

Generally, third-party libraries provide developers with the unique opportunity to integrate pre-tested, reusable software that saves development time and cost. This allows the developer to focus on the core features of the game that matter to players. Mobile apps and games often share data.

What is one risk of using a third party library?

While most critical vulnerabilities in third-party libraries are disclosed as Common Vulnerabilities and Exposures (CVEs), it is disconcerting to note that the applications that use them are not updated in a timely manner.

What is third party library in Android?

The third-party libraries are reusable resources that are widely employed in Android Apps. While the third-party libraries provide a variety of functions, they bring serious security and privacy problems. The third-party libraries and the host Apps run in the same process and share the same permissions.


1 Answers

Try out TARGET_LINK_LIBRARIES(ntctrl), the -l flag should not be used there (guess from what I have in mind)

This is how I would write the cmake file:

include_directories(/opt/norton/inc)
link_directories(/opt/norton/lib)
add_executable(application initialize_nw)
target_link_libraries(application ntctrl)

To show what are the actual command lines run during a make, use:

make VERBOSE=1

Maybe this shows you the difference between what you ran manually and the cmake generated commands.

like image 86
jdehaan Avatar answered Oct 12 '22 09:10

jdehaan