Wednesday, April 26, 2023

GCC


some tips when i trying compile opengl programs in conda
  • g++ -I/home/hongy19/miniconda3/envs/opengl/include/ : include *.h
  • g++ -L/home/hongy19/miniconda3/envs/opengl/lib   :add folder of *.so for link(ld)
  • g++ -lglfw: use libglfw.so for link(ld)
  • LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hongy19/miniconda3/envs/opengl/lib ./a.out: add library search path for dynamic *.so 
  • static compile
    • -static compile for static link need *.a and *.o library and *.so doesn't work for static compile, see link.  The error of following code is due to missing of *.a or *.o even *.so existed.
(opengl) hongy19@WSL opengl$ gcc glfw-1.cpp -static -lglfw -lGL
/usr/sbin/ld: cannot find -lglfw: No such file or directory
/usr/sbin/ld: cannot find -lGL: No such file or directory
collect2: error: ld returned 1 exit status

  • pkgconfig
    • PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --list-all
    • PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --cflags glfw3 -I/home/hongy19/miniconda3/envs/opengl/include
    • PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --cflags  gtk+-3.0

No comments: