I’m trying to build a binary from a static lib and a header file. It works perfectly on Windows but on Linux(Ubuntu 22.04) it does not want to work.
This is my CMake file(I have not added the windows part to make it clearer)
<code>make_minimum_required(VERSION 3.19)
# Set the project name and C++ standard
project(Main)
set(CMAKE_CXX_STANDARD 17)
# Add the header file directory
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../src")
# Find the static library
set(SIMPROTOCOL_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../out/build/linux-release")
find_library(SIMPROTOCOL_LIB NAMES SimLib PATHS ${SIMPROTOCOL_LIB_DIR} NO_DEFAULT_PATH)
set(SOURCE_FILES main.cpp)
# Define the executable that is built from the source file
add_executable(Main${SOURCE_FILES})
target_link_libraries(Main PRIVATE ${SIMPROTOCOL_LIB})
</code>
<code>make_minimum_required(VERSION 3.19)
# Set the project name and C++ standard
project(Main)
set(CMAKE_CXX_STANDARD 17)
# Add the header file directory
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../src")
# Find the static library
set(SIMPROTOCOL_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../out/build/linux-release")
find_library(SIMPROTOCOL_LIB NAMES SimLib PATHS ${SIMPROTOCOL_LIB_DIR} NO_DEFAULT_PATH)
set(SOURCE_FILES main.cpp)
# Define the executable that is built from the source file
add_executable(Main${SOURCE_FILES})
target_link_libraries(Main PRIVATE ${SIMPROTOCOL_LIB})
</code>
make_minimum_required(VERSION 3.19)
# Set the project name and C++ standard
project(Main)
set(CMAKE_CXX_STANDARD 17)
# Add the header file directory
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../src")
# Find the static library
set(SIMPROTOCOL_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../out/build/linux-release")
find_library(SIMPROTOCOL_LIB NAMES SimLib PATHS ${SIMPROTOCOL_LIB_DIR} NO_DEFAULT_PATH)
set(SOURCE_FILES main.cpp)
# Define the executable that is built from the source file
add_executable(Main${SOURCE_FILES})
target_link_libraries(Main PRIVATE ${SIMPROTOCOL_LIB})
It basically says
<code>[cmake] CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
[cmake] Please set them or make sure they are set and tested correctly in the CMake files:
[cmake] SIMPROTOCOL_LIB
</code>
<code>[cmake] CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
[cmake] Please set them or make sure they are set and tested correctly in the CMake files:
[cmake] SIMPROTOCOL_LIB
</code>
[cmake] CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
[cmake] Please set them or make sure they are set and tested correctly in the CMake files:
[cmake] SIMPROTOCOL_LIB
Other notes:
- It builds when I invoke the g++ with the arguments and everything pointing to the header files and the static lib
- My path name has spaces but I changed the path of the static lib to a different one with no spaces and it does not work with CMake
- Yes, I’ve reviewed the path to the static lib, the path is correct
If this doesn’t work, I’ll just create a Makefile but I rather make it work with CMake.
Thanks in advance!
1