LiangliangNan / Easy3D

A lightweight, easy-to-use, and efficient C++ library for processing and rendering 3D data
GNU General Public License v3.0
1.37k stars 245 forks source link

Buliging own project on Visual Studio Code not finding Easy3D_RESOURCE_DIR #184

Closed lfescobarc closed 5 months ago

lfescobarc commented 5 months ago

I am using Visual Studio Code to build a custom project, using some Easy3D libraries, I followed the instructions provided in the readme, I am trying to include the resource_dir, but every time I am getting an error saying that 'Easy3D_RESOURCE_DIR' was not declared in this scope, here is what I am using as my CMakeLists.txt

cmake_minimum_required(VERSION 3.12) project(MyProject)

Specify the C++ standard

set(CMAKE_CXX_STANDARD 11)

Find Easy3D components

find_package(Easy3D COMPONENTS viewer core REQUIRED)

Set paths to Easy3D installation directory and resources directory

set(Easy3D_DIR "/home/luis/Easy3D/Release") set(Easy3D_RESOURCE_DIR "/home/luis/Easy3D/resources")

Create an executable target

add_executable(Test pcd_write.cpp)

Link the Test executable with necessary Easy3D modules

target_link_libraries(Test PRIVATE easy3d::viewer easy3d::core)

Set include directories for the Test target

target_include_directories(Test PRIVATE ${Easy3D_INCLUDE_DIR})

LiangliangNan commented 5 months ago

set(Easy3D_DIR "/home/luis/Easy3D/Release") set(Easy3D_RESOURCE_DIR "/home/luis/Easy3D/resources")

This is not the recommended way of helping CMake to find Easy3D. You can specify Easy3D_DIR in the CMake UI. Or, try to run CMake (of course you will see the error of "failed to find Easy3D"), and then provide Easy3D_DIR in the generated CMake cache file. Then run CMake again.

set(Easy3D_RESOURCE_DIR "/home/luis/Easy3D/resources")

This is not needed. Even if you do so, it will be known only to CMake but not accessible to your C++ code. As explained in the ReadMe file, once Easy3D has been successfully found, the required Easy3D libraries, the include directories and compile definitions of Easy3D will be automatically visible and accessible to your project.

target_include_directories(Test PRIVATE ${Easy3D_INCLUDE_DIR})

You don't need this line of code.

lfescobarc commented 5 months ago

Thank you for your response. I am able to build my project; I was trying to debug it using Visual Code Studio. I am not able to run and debug directly in that interface; if you have any other recommendations, I will be happy to test them.

LiangliangNan commented 5 months ago

If you have successfully built the project, you should not have any problem running it. The debugging should be the same as for any other C++ based programs.

I think your question is more about the usage of Visual Code Studio, which is not an Easy3D specific issue. So I will close this issue. Please try to use any IDE that you're most familiar with for debugging.