2

I want to include the draco library for my c++ project and I built draco with cmake on ubuntu. When i try to add any draco header i see "include errors". I've tried to compile header file and this command worked for some drace headers but didnt find many on them.

g++ -I "\\wsl$\Ubuntu\home\antmedia\draco\src\draco" ObjContainer.cpp

error: " No such file or directory #include "draco/compression/config/compression_shared.h"

I saw this in draco readme. But i did not get it.

" If you'd like to add decoding to your applications you will need to include the draco_dec library. "

What does it means? How can i add draco_dec liblary?

after, try to - v:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
COLLECT_GCC_OPTIONS='-I' '~localinclude' '-L~locallib' '-o' 'prog' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -I ~localinclude -imultiarch x86_64-linux-gnu -D_GNU_SOURCE ObjContainer.cpp -quiet -dumpbase ObjContainer.cpp -mtune=generic -march=x86-64 -auxbase ObjContainer -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cci0iuOa.s
GNU C++14 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "~localinclude"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/7
 /usr/include/x86_64-linux-gnu/c++/7
 /usr/include/c++/7/backward
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++14 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3eb3dc290cd5714c3e1c3ae751116f07
In file included from ObjContainer.cpp:11:0:
ObjContainer.h:11:10: fatal error: draco/compression/encode.h: No such file or directory
 #include "draco/compression/encode.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
badcode
  • 581
  • 1
  • 9
  • 28
  • Hmm, I just realized that you are trying to use the draco libraries from _outside_ `wsl`. Is that correct? I'm 100% sure that what you build inside `wsl` will work with the `g++` you are using in a Windows CMD.EXE window. – Ted Lyngmo Jun 10 '20 at 22:18

2 Answers2

1

Looking at the project's source tree, I think you just got the path wrong; there is indeed no such directory as draco/src/draco/draco/compression.

You already specified the draco subdirectory in your #include directive, so take it off the include path:

g++ -I "\\wsl$\Ubuntu\home\antmedia\draco\src" ObjContainer.cpp
Asteroids With Wings
  • 17,071
  • 2
  • 21
  • 35
1

For convenience, install the downloaded library in a directory where you keep all the libraries you download and compile yourself. Start by creating such a directory. Example:

  • mkdir ~/local

You then need to configure the Draco project to be installed in that location before building. Inside the draco/build_dir directory, do:

  • cmake -DCMAKE_INSTALL_PREFIX=~/local ..

After you've executed cmake above you should make (or make -j to make it faster) to build the libraries and you can combine that with installing the result at the same time:

  • make -j install

Draco creates three libraries:

  • draco
  • dracodec
  • dracoenc

draco_dec mentioned in the README is probably an old name (or a typo) so include dracodec by adding the compiler option -ldracodec at the end of your g++ line.

When compiling your own code. Add -I to point at the newly created include directory and -L to point at where the newly created libraries are stored:

  • g++ -I "\\wsl$\Ubuntu\home\antmedia\local\include" -L "\\wsl$\Ubuntu\home\antmedia\local\lib" -o prog ObjContainer.cpp -ldracodec

The \\wsl$ paths should only be used if you're trying to access your wsl directory from Windows (e.g. a CMD.EXE window). If you are trying to compile ObjContainer.cpp from within the wsl, compile your own code like this instead:

  • g++ -I ~/local/include -L ~/local/lib -o prog ObjContainer.cpp -ldracodec

By always installing the external libraries that you build using cmake and make in the same directory in your home (~/local) you can use the same two -I and -L options for everything you've installed there.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • That was a great answer sir! I did the all steps. and I have three folders in my local. bin, include,lib. btw i added the "~\local\include" path to "include path" in vs code and there is no error line now. But when i try to run this command g++ -I ~\local\include -L ~\local\lib -o prog ObjContainer.cpp -ldracodec this error occurs: #include "draco/compression/encode.h" compilation terminated. I checked it. There is encode.h in that directory but cant find. – badcode Jun 10 '20 at 22:54
  • Thanks! Ok, then add `-v` to the compilation command and copy all the output that gives and put in the question. It may provide useful hints. – Ted Lyngmo Jun 11 '20 at 05:51
  • 1
    @badcode also note that I just changed the backslashes to forward slashes in the last compilation command. I was tired when I wrote the answer yesterday :-) – Ted Lyngmo Jun 11 '20 at 07:15