dpilger26 / NumCpp

C++ implementation of the Python Numpy library
https://dpilger26.github.io/NumCpp
MIT License
3.52k stars 547 forks source link

fatal error: 'NumCpp/Coordinates/Coordinate.hpp' file not found #124

Closed wingdi closed 2 years ago

wingdi commented 2 years ago

I have add this in CMakelists.txt: include_directories(NumCpp NumCpp/Coordinates) Why can't find it ?

dpilger26 commented 2 years ago

You probably haven't included the directory correctly. You should be using target_include_directories in place of include_directories now-a-days. You've put in the path NumCpp/Coordinates as a relative path to your build directory and probably have it incorrect. For example if your project was setup like this:

MyProject/
├── CMakeLists.txt
├── NumCpp
│   └── Coordinates
├── build
└── mySource.cpp

then your CMakeLists.txt would look like:

project(MyProject CXX)
add_executable(${PROJECT_NAME} mySource.cpp)
target_include_directories(${PROJECT_NAME}, ${CMAKE_CURRENT_BUILD_DIR}/../NumCpp/Coordinates)

To build you would:

>> cd build
>> cmake ..
>> cmake --build . --target MyProject
wingdi commented 2 years ago

Very thanks for your reply .

Here is a test Project:

This is CMakeLists.txt :

截屏2021-12-05 下午1 01 02

This is mySource.cpp:

截屏2021-12-05 下午1 01 14

This is NumCpp folder copied from NumCpp-master/include :

截屏2021-12-05 下午1 01 51

Developing tool is CLion.

It still get this error . even use file(glob .. ) , still didn't solve it.

dpilger26 commented 2 years ago

I guess I don't understand why you are including the NumCpp/Coordinates directory if you aren't specifically including any of the files from that directory? In your example above you are including the top level NumCpp.hpp header so you will need to include the directory that that file is in. eg.

target_include_directories({$PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
wingdi commented 2 years ago

Actually i want to include all the NumCpp, because the report error is about NumCpp/Coordinates , so i start solve from it..
Now problem solved, thanks very much !