In C++, I have a library path I know how include when building with a CMakeLists.txt file but I don't know how to include it when building with a Makefile.
I tried applying the solution asked and answered here but it didn't work. The contents of the Makefile is below. The library's name is "NumCpp". The full path to this library on my computer is C:\Users\ooo\tor\Robot\rainbow\NumCpp\include\
.
In the .cc file I am including the library as #include "NumCpp.hpp"
This is the CMakeLists.txt file. This would include and compile the NumCpp library if you ran this in the directory containing NumCpp. I don't know if it is helpful to show this, but I know I can include the library this way.
cmake_minimum_required(VERSION 3.14)
project("HelloWorld" CXX)
add_executable(${PROJECT_NAME} main.cpp)
find_package(NumCpp 2.6.2 REQUIRED)
target_link_libraries(${PROJECT_NAME}
NumCpp::NumCpp
)
The Makefile. I tried using INC_DIR
, CFLAGS
, and DEPS
to link the path to the library but I'm getting an error.
COMMON=/O2 /MT /EHsc /arch:AVX /I../include /Fe../bin/
cl_vars = 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx86\x86\cl.exe'
cl_var = 'cl'
INC_DIR = C:/Users/ooo/tor/Robot/rainbow/NumCpp/include/
CFLAGS=-c -Wall -I$(INC_DIR)
DEPS = NumCpp.hpp
all:
$(cl_var) $(COMMON) testxml.cc ../bin/mujoco210nogl.lib
$(cl_var) $(COMMON) testspeed.cc ../bin/mujoco210nogl.lib
$(cl_var) $(COMMON) compile.cc ../bin/mujoco210nogl.lib
$(cl_var) $(COMMON) derivative.cc /openmp ../bin/mujoco210nogl.lib
$(cl_var) $(COMMON) basic.cc ../bin/glfw3.lib ../bin/mujoco210.lib
$(cl_var) $(COMMON) record.cc ../bin/glfw3.lib ../bin/mujoco210.lib
$(cl_var) $(COMMON) simulate.cc ../include/uitools.c ../bin/glfw3.lib ../bin/mujoco210.lib
del *.obj
The error...
simulate.cc(14): fatal error C1083: Cannot open include file: 'NumCpp.hpp': No such file or directory
Generating Code...
Compiling...
uitools.c
Generating Code...
make: *** [Makefile:16: all] Error 2