Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake build error 'epoxy::epoxy' not found #936

Closed
KaranBalakumar opened this issue Jun 2, 2024 · 7 comments · Fixed by #937
Closed

CMake build error 'epoxy::epoxy' not found #936

KaranBalakumar opened this issue Jun 2, 2024 · 7 comments · Fixed by #937

Comments

@KaranBalakumar
Copy link

KaranBalakumar commented Jun 2, 2024

[ 25%] Building CXX object CMakeFiles/coordinateTransform.dir/coordinateTransform.o
[ 50%] Linking CXX executable coordinateTransform
[ 50%] Built target coordinateTransform
[ 75%] Building CXX object CMakeFiles/plotTrajectory.dir/plotTrajectory.o
[100%] Linking CXX executable plotTrajectory
/usr/bin/ld: cannot find -lepoxy::epoxy: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/plotTrajectory.dir/build.make:114: plotTrajectory] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/plotTrajectory.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Initially the error came up saying even -lOpengl::EGL could not be found, but I edited the CMakeLists.txt as shown below

include_directories("/usr/include/eigen3")
add_executable(coordinateTransform coordinateTransform.cpp)

find_package(Pangolin REQUIRED)
find_package(OpenGL REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS} ${OpenGL_INCLUDE_DIRS})
add_executable(plotTrajectory plotTrajectory.cpp)
target_link_libraries(plotTrajectory ${Pangolin_LIBRARIES})

and the /usr/bin/ld: cannot find -lOpenGL::EGL No such file or directory was gone but still the /usr/bin/ld: cannot find -lepoxy::epoxy: No such file or directory error persists. I also have libepoxy-dev installed through sudo apt-get install libepoxy-dev

The plotTrajectory.cpp code is below,

#include <pangolin/pangolin.h>
#include <Eigen/Core>
#include <unistd.h>

using namespace std;
using namespace Eigen;

// path to trajectory file
string trajectory_file = "./examples/trajectory.txt";

void DrawTrajectory(vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>>);

int main(int argc, char **argv) {

  vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> poses;
  ifstream fin(trajectory_file);
  if (!fin) {
    cout << "cannot find trajectory file at " << trajectory_file << endl;
    return 1;
  }

  while (!fin.eof()) {
    double time, tx, ty, tz, qx, qy, qz, qw;
    fin >> time >> tx >> ty >> tz >> qx >> qy >> qz >> qw;
    Isometry3d Twr(Quaterniond(qw, qx, qy, qz));
    Twr.pretranslate(Vector3d(tx, ty, tz));
    poses.push_back(Twr);
  }
  cout << "read total " << poses.size() << " pose entries" << endl;

  // draw trajectory in pangolin
  DrawTrajectory(poses);
  return 0;
}

/*******************************************************************************************/
void DrawTrajectory(vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> poses) {
  // create pangolin window and plot the trajectory
  pangolin::CreateWindowAndBind("Trajectory Viewer", 1024, 768);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  pangolin::OpenGlRenderState s_cam(
    pangolin::ProjectionMatrix(1024, 768, 500, 500, 512, 389, 0.1, 1000),
    pangolin::ModelViewLookAt(0, -0.1, -1.8, 0, 0, 0, 0.0, -1.0, 0.0)
  );

  pangolin::View &d_cam = pangolin::CreateDisplay()
    .SetBounds(0.0, 1.0, 0.0, 1.0, -1024.0f / 768.0f)
    .SetHandler(new pangolin::Handler3D(s_cam));

  while (pangolin::ShouldQuit() == false) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    d_cam.Activate(s_cam);
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glLineWidth(2);
    for (size_t i = 0; i < poses.size(); i++) {
      //Draw Poses
      Vector3d Ow = poses[i].translation();
      Vector3d Xw = poses[i] * (0.1 * Vector3d(1, 0, 0));
      Vector3d Yw = poses[i] * (0.1 * Vector3d(0, 1, 0));
      Vector3d Zw = poses[i] * (0.1 * Vector3d(0, 0, 1));
      glBegin(GL_LINES);
      glColor3f(1.0, 0.0, 0.0);
      glVertex3d(Ow[0], Ow[1], Ow[2]);
      glVertex3d(Xw[0], Xw[1], Xw[2]);
      glColor3f(0.0, 1.0, 0.0);
      glVertex3d(Ow[0], Ow[1], Ow[2]);
      glVertex3d(Yw[0], Yw[1], Yw[2]);
      glColor3f(0.0, 0.0, 1.0);
      glVertex3d(Ow[0], Ow[1], Ow[2]);
      glVertex3d(Zw[0], Zw[1], Zw[2]);
      glEnd();
    }
    //Draw connections
    for (size_t i = 0; i < poses.size(); i++) {
      glColor3f(0.0, 0.0, 0.0);
      glBegin(GL_LINES);
      auto p1 = poses[i], p2 = poses[i + 1];
      glVertex3d(p1.translation()[0], p1.translation()[1], p1.translation()[2]);
      glVertex3d(p2.translation()[0], p2.translation()[1], p2.translation()[2]);
      glEnd();
    }
    pangolin::FinishFrame();
    usleep(5000);   // sleep 5 ms
  }
}
@christian-rauch
Copy link
Collaborator

Can you provide details about your system and your build steps?

If you install the dependencies as per instructions via install_prerequisites.sh, the dependencies will be installed.

The CMake symbols with :: are CMake targets that are created via the respective packages, e.g. the target OpenGL::EGL is created via find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL) and epoxy::epoxy is created via find_package(epoxy REQUIRED). Are you using an old CMake?

@KaranBalakumar
Copy link
Author

I run an Ubuntu 22.04 and for the build steps, I followed this,

./scripts/install_prerequisites.sh recommended
cmake -B build -GNinja
cmake --build build
cmake version 3.29.3

and when I add find_package(epoxy REQUIRED) to CMakeLists.txt whose code is below,

include_directories("/usr/include/eigen3")
add_executable(coordinateTransform coordinateTransform.cpp)

set(CMAKE_CXX_STANDARD 14)

find_package(Pangolin REQUIRED)
find_package(OpenGL REQUIRED)
find_package(epoxy REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS} ${OpenGL_INCLUDE_DIRS} ${epoxy_INCLUDE_DIRS})
add_executable(plotTrajectory plotTrajectory.cpp)
target_link_libraries(plotTrajectory ${Pangolin_LIBRARIES})

I get the following error

CMake Error at CMakeLists.txt:8 (find_package):
  By not providing "Findepoxy.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "epoxy", but
  CMake did not find one.

  Could not find a package configuration file provided by "epoxy" with any of
  the following names:

    epoxyConfig.cmake
    epoxy-config.cmake

  Add the installation prefix of "epoxy" to CMAKE_PREFIX_PATH or set
  "epoxy_DIR" to a directory containing one of the above files.  If "epoxy"
  provides a separate development package or SDK, be sure it has been
  installed.


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.29)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

@KaranBalakumar
Copy link
Author

KaranBalakumar commented Jun 2, 2024

so this is how I found a solution, I took inspiration from this link FindEpoxy.cmake module to make a libraryepoxy:epoxy by importing its properties from the libepoxy-dev library installed in my computer and added it to my project folder
and added this new FindEpoxy.cmake module to my CMakeLists.txt by adding the lines

set(CMAKE_MODULE_PATH "path/to/FindEpoxyModule/")
find_package(epoxy REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS} ${OpenGL_INCLUDE_DIRS} ${epoxy_INCLUDE_DIRS})

@christian-rauch
Copy link
Collaborator

find_package(epoxy REQUIRED)

It is still not clear to me what exactly you are doing. This find_package is already done in Pangolin:

find_package(epoxy REQUIRED)

so you should not need to add it again to any of the CMakeLists.txt.

And the file coordinateTransform.cpp is not part of Pangolin.

Can you please state exactly, step-by-step, what you are doing and how this can be reproduced on a fresh Ubuntu? Feel free to add a script or Docker run file that reproduces this.

@christian-rauch
Copy link
Collaborator

I can reproduce this now by using Pangolin as an external project. @Uchiha729 Can you check if #937 solves the problem for you without your find_package workarounds that manually search for OpenGL and epoxy?

@KaranBalakumar
Copy link
Author

I can reproduce this now by using Pangolin as an external project. @Uchiha729 Can you check if #937 solves the problem for you without your find_package workarounds that manually search for OpenGL and epoxy?

YES!!!

@nabang1010
Copy link

run sudo apt-get install libepoxy-dev to install lib epoxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants