Includes don't work correctly when building my project
Karin-Sugi opened this issue · 1 comments
Hi, I am a chrono beginner. Now I have a example project code which is similar to what I'd like to.
I'm trying to build it, but some includes don't work correctly and returns error message saying 1>C:\chrono_workspace\chrono\src\chrono/core/ChApiCE.h(18,10): fatal error C1083: cannot open include file. 'chrono/ChVersion.h':No such file or directory
.
I use chrono on windows. Thus, slashes in the path are quite wired... Anyway, I know this is CMakeList problem. The include file: ChVersion.h
is in C:\chrono_workspace\chrono_build\chrono
, but the compiler is looking for it in other path.
How can I fix it?
My CMakeList is below.
cmake_minimum_required(VERSION 3.0.0)
project(husky-chrono VERSION 0.1.0)
# set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11 -O3")
set(CMAKE_CXX_FLAGS "-std=c++11 -O3")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
include(CTest)
enable_testing()
set(SOURCE_FILES main.cc husky.cc husky.hh)
add_executable(husky-chrono ${SOURCE_FILES})
# Chrono
# target_include_directories(husky-chrono PUBLIC /usr/local/include/)
target_include_directories(husky-chrono PUBLIC "C:/chrono_workspace/chrono/src/")
# target_include_directories(husky-chrono PUBLIC "C:/chrono_workspace/chrono_build/chrono/")
target_link_libraries(husky-chrono LINK_PUBLIC ChronoEngine ChronoEngine_vehicle ChronoModels_robot ChronoEngine_irrlicht ChronoEngine_vehicle_irrlicht)
# Eigen
target_include_directories(husky-chrono PUBLIC /usr/include/eigen3/)
# Bullet
# target_include_directories(husky-chrono PUBLIC /usr/local/include/chrono/collision/bullet/)
target_include_directories(husky-chrono PUBLIC "C:/chrono_workspace/chrono/src/chrono/collision/bullet/")
# Irrlicht
target_include_directories(husky-chrono PUBLIC /usr/include/irrlicht/)
# Python
target_include_directories(husky-chrono PUBLIC /usr/include/python3.10)
target_link_libraries(husky-chrono LINK_PUBLIC -lpython3.10)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Thanks in advance,
Karin
Hi Karin,
if you want to properly link to Chrono libraries we offer a template project that clearly tells how to do it.
And it's much simpler and more complete than what you are doing by hand! In fact, you might have easily forgot some include in your CMakeLists.
Please check the template_project folder in the repo!
BTW, we recommend you, for any other question, to ask in the Google Forum.
This is the better place where to ask question related to single-user issues.
We use GitHub Issues only to track issues related to our code!