CMake error when try to add external library
I need to add an external library in my project.
Here is the project structure:
/- src/
- my source files here…
|- dist/
|- FLTK
|- lib/
|- libfltk.a
|- libfltk_forms.a
|- FL
|- build/
|- main.cpp
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
find_library(LibFltk ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk.a)
find_library(LibFltk_Forms ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk_forms.a)
if(APPLE)
find_library(COCOA Cocoa)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${LibFltk} ${COCOA})
Error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LibFltk
linked by target "keyplay" in directory /Users/coder/Desktop/sandbox/keyplay
-- Configuring incomplete, errors occurred!
When I try to compile my project from terminal it works perfect.
This is how I do it:
g++ -std=c++17 -c main.cpp -I dist/FLTK
&& g++ main.o -o main -L dist/FLTK/lib -lfltk_forms
-lfltk_images
-lfltk
-lfltk_gl
-framework Cocoa
&& ./main
What is wrong in my CMakeLists.txt?
Thanks.
c++ cmake fltk
add a comment |
I need to add an external library in my project.
Here is the project structure:
/- src/
- my source files here…
|- dist/
|- FLTK
|- lib/
|- libfltk.a
|- libfltk_forms.a
|- FL
|- build/
|- main.cpp
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
find_library(LibFltk ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk.a)
find_library(LibFltk_Forms ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk_forms.a)
if(APPLE)
find_library(COCOA Cocoa)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${LibFltk} ${COCOA})
Error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LibFltk
linked by target "keyplay" in directory /Users/coder/Desktop/sandbox/keyplay
-- Configuring incomplete, errors occurred!
When I try to compile my project from terminal it works perfect.
This is how I do it:
g++ -std=c++17 -c main.cpp -I dist/FLTK
&& g++ main.o -o main -L dist/FLTK/lib -lfltk_forms
-lfltk_images
-lfltk
-lfltk_gl
-framework Cocoa
&& ./main
What is wrong in my CMakeLists.txt?
Thanks.
c++ cmake fltk
1
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?
– Matthieu Brucher
Nov 25 '18 at 12:03
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13
add a comment |
I need to add an external library in my project.
Here is the project structure:
/- src/
- my source files here…
|- dist/
|- FLTK
|- lib/
|- libfltk.a
|- libfltk_forms.a
|- FL
|- build/
|- main.cpp
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
find_library(LibFltk ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk.a)
find_library(LibFltk_Forms ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk_forms.a)
if(APPLE)
find_library(COCOA Cocoa)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${LibFltk} ${COCOA})
Error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LibFltk
linked by target "keyplay" in directory /Users/coder/Desktop/sandbox/keyplay
-- Configuring incomplete, errors occurred!
When I try to compile my project from terminal it works perfect.
This is how I do it:
g++ -std=c++17 -c main.cpp -I dist/FLTK
&& g++ main.o -o main -L dist/FLTK/lib -lfltk_forms
-lfltk_images
-lfltk
-lfltk_gl
-framework Cocoa
&& ./main
What is wrong in my CMakeLists.txt?
Thanks.
c++ cmake fltk
I need to add an external library in my project.
Here is the project structure:
/- src/
- my source files here…
|- dist/
|- FLTK
|- lib/
|- libfltk.a
|- libfltk_forms.a
|- FL
|- build/
|- main.cpp
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
find_library(LibFltk ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk.a)
find_library(LibFltk_Forms ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/libfltk_forms.a)
if(APPLE)
find_library(COCOA Cocoa)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/build/main ${LibFltk} ${COCOA})
Error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LibFltk
linked by target "keyplay" in directory /Users/coder/Desktop/sandbox/keyplay
-- Configuring incomplete, errors occurred!
When I try to compile my project from terminal it works perfect.
This is how I do it:
g++ -std=c++17 -c main.cpp -I dist/FLTK
&& g++ main.o -o main -L dist/FLTK/lib -lfltk_forms
-lfltk_images
-lfltk
-lfltk_gl
-framework Cocoa
&& ./main
What is wrong in my CMakeLists.txt?
Thanks.
c++ cmake fltk
c++ cmake fltk
asked Nov 25 '18 at 11:48
Levon SarkisovLevon Sarkisov
1818
1818
1
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?
– Matthieu Brucher
Nov 25 '18 at 12:03
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13
add a comment |
1
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?
– Matthieu Brucher
Nov 25 '18 at 12:03
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13
1
1
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?– Matthieu Brucher
Nov 25 '18 at 12:03
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?– Matthieu Brucher
Nov 25 '18 at 12:03
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13
add a comment |
2 Answers
2
active
oldest
votes
The find_library
function expects the second argument to be the filename you are targeting (http://www.cmake.org/cmake/help/v3.0/command/find_library.html), and you need to specify the paths where to look as additional arguments:
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
find_library(LibFltk_Forms libfltk_forms.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
add a comment |
Thanks to @Matthieu Brucher. Here is correct config:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(keyplay ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
if(APPLE)
find_library(COCOA Cocoa)
endif()
target_link_libraries(keyplay ${LibFltk} ${COCOA})
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467121%2fcmake-error-when-try-to-add-external-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The find_library
function expects the second argument to be the filename you are targeting (http://www.cmake.org/cmake/help/v3.0/command/find_library.html), and you need to specify the paths where to look as additional arguments:
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
find_library(LibFltk_Forms libfltk_forms.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
add a comment |
The find_library
function expects the second argument to be the filename you are targeting (http://www.cmake.org/cmake/help/v3.0/command/find_library.html), and you need to specify the paths where to look as additional arguments:
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
find_library(LibFltk_Forms libfltk_forms.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
add a comment |
The find_library
function expects the second argument to be the filename you are targeting (http://www.cmake.org/cmake/help/v3.0/command/find_library.html), and you need to specify the paths where to look as additional arguments:
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
find_library(LibFltk_Forms libfltk_forms.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
The find_library
function expects the second argument to be the filename you are targeting (http://www.cmake.org/cmake/help/v3.0/command/find_library.html), and you need to specify the paths where to look as additional arguments:
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
find_library(LibFltk_Forms libfltk_forms.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
edited Nov 25 '18 at 12:31
answered Nov 25 '18 at 12:13
Matthieu BrucherMatthieu Brucher
16.5k32143
16.5k32143
add a comment |
add a comment |
Thanks to @Matthieu Brucher. Here is correct config:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(keyplay ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
if(APPLE)
find_library(COCOA Cocoa)
endif()
target_link_libraries(keyplay ${LibFltk} ${COCOA})
add a comment |
Thanks to @Matthieu Brucher. Here is correct config:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(keyplay ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
if(APPLE)
find_library(COCOA Cocoa)
endif()
target_link_libraries(keyplay ${LibFltk} ${COCOA})
add a comment |
Thanks to @Matthieu Brucher. Here is correct config:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(keyplay ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
if(APPLE)
find_library(COCOA Cocoa)
endif()
target_link_libraries(keyplay ${LibFltk} ${COCOA})
Thanks to @Matthieu Brucher. Here is correct config:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK)
add_executable(keyplay ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
if(APPLE)
find_library(COCOA Cocoa)
endif()
target_link_libraries(keyplay ${LibFltk} ${COCOA})
answered Nov 25 '18 at 12:12
Levon SarkisovLevon Sarkisov
1818
1818
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467121%2fcmake-error-when-try-to-add-external-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have you tried (cmake.org/cmake/help/v3.0/command/find_library.html)
find_library(LibFltk libfltk.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/dist/FLTK/lib/)
?– Matthieu Brucher
Nov 25 '18 at 12:03
Thanks Matthieu, it helped me!
– Levon Sarkisov
Nov 25 '18 at 12:11
Did it solve the issue? If yes, I'll make it an answer.
– Matthieu Brucher
Nov 25 '18 at 12:12
Yes, Matthieu, it was the correct answer.
– Levon Sarkisov
Nov 25 '18 at 12:13