[CMake] CMake and BZip2
Kristian
kristianonline28 at gmail.com
Thu Feb 11 17:56:54 EST 2016
Hey,
I have a small C++ file, which uses some functions of the library
bzip2. On a Debian derivate, I have installed needed packages with
* sudo apt-get install bzip2 libzip2 libbz2-dev
Here is my CMakeLists.txt:
=============================
project(bzip2Example)
cmake_minimum_required(VERSION 2.8)
find_package(BZip2)
include_directories(${BZIP2_INCLUDE_DIR})
target_link_libraries(${BZIP2_LIBRARIES})
set(BZIP2_EX_SRC main.cpp)
add_executable(${PROJECT_NAME} ${BZIP2_EX_SRC})
=============================
Then I type in: cmake . && make
This is the output of the make command:
=============================
main.cpp: In function ‘int main(int, char**)’:
main.cpp:8:21: warning: deprecated conversion from string constant to
‘char*’ [-Wwrite-strings]
char *sourceFile = "test.txt";
^
main.cpp:9:21: warning: deprecated conversion from string constant to
‘char*’ [-Wwrite-strings]
char *targetFile = "test.bz2";
^
Linking CXX executable bzip2Ex
CMakeFiles/bzip2Ex.dir/main.cpp.o: In Funktion `main':
main.cpp:(.text+0x15c): Nicht definierter Verweis auf `BZ2_bzWriteOpen'
main.cpp:(.text+0x193): Nicht definierter Verweis auf `BZ2_bzWrite'
main.cpp:(.text+0x1db): Nicht definierter Verweis auf `BZ2_bzWriteClose'
main.cpp:(.text+0x267): Nicht definierter Verweis auf `BZ2_bzWriteClose'
collect2: error: ld returned 1 exit status
make[2]: *** [bzip2Ex] Fehler 1
make[1]: *** [CMakeFiles/bzip2Ex.dir/all] Fehler 2
make: *** [all] Fehler 2
=============================
Why there is the error?
More information about the CMake
mailing list