Link error- Ubuntu 22.04

I have managed to compile the latest opennurbs release in Ubuntu. However, the linker throws an error while generating the example files. Please help


g++ -luuid example_read/example_read.o example_userdata/example_ud.o -L. -lopennurbs_public -lm -o example_read/example_read
/usr/bin/ld: ./libopennurbs_public.a(gen_uuid.o): in function `uuid__generate_time':
gen_uuid.c:(.text+0xba1): undefined reference to `uuid_pack'
/usr/bin/ld: ./libopennurbs_public.a(gen_uuid.o): in function `uuid_generate_time':
gen_uuid.c:(.text+0xdda): undefined reference to `uuid_pack'
/usr/bin/ld: gen_uuid.c:(.text+0xe07): undefined reference to `uuid_unpack'
/usr/bin/ld: ./libopennurbs_public.a(gen_uuid.o): in function `uuid__generate_random':
gen_uuid.c:(.text+0xea2): undefined reference to `uuid_unpack'
/usr/bin/ld: gen_uuid.c:(.text+0xed0): undefined reference to `uuid_pack'
collect2: error: ld returned 1 exit status
make: *** [makefile:917: example_read/example_read] Error 1

Can you give some more information on how you build this on Ubuntu. Do you use CMake? Which opennurbs version are you using exactly and where did you obtain it? (the latest release being 8.8.24166.15000).

I’m trying to reproduce this with CMake, but I’m not seeing the error messages you see. Probably because the default CMake build only builds the library and not the examples.

Hi @menno,
Cloned the repository GitHub - mcneel/opennurbs: OpenNURBS libraries allow anyone to read and write the 3DM file format without the need for Rhino.
I hope that is the latest build.

Yes, CMake compiles the library, but gives the same error when trying to compile my code that contains uuid reference.

I modified the Makefile that was included in the distribution. the changes are as follows

1,
ar qvl changed to ar qv
the argument l gives an error

2,
added LINKFLAGS = -luuid

make successfully compiles the library but fails on the example file. BTW I am on Ubuntu 22.04 WSL with the latest updates.

Please let me know if I need to add some extra instructions while compiling.

Thanks in advance

I see that too with the makefile. It looks like that is not up-to-date, I made a ticket for that at https://mcneel.myjetbrains.com/youtrack/issue/RH-82660/

The CMake build, however, will build libOpenNURBS.so with the UUID code from the android_uuid subdirectory inside it. When I build opennurbs with cmake in the directory build inside the source tree, by issuing the following commands to build first OpenNURRBS, then the example_read, it compiles and runs:

export SOURCE_ROOT=<path/to/source>
# make OpenNURBS shared library
cd $SOURCE_ROOT
mkdir $SOURCE_ROOT/build
cd $SOURCE_ROOT/build
cmake ..
make
#compile the example
cd $SOURCE_ROOT/example_read
g++ -o example_read example_read.cpp -L $SOURCE_ROOT/build -lOpenNURBS

Then by setting the dynamic library path to the build output to ensure libOpenNURBS.so can be found, I can execute example_read:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SOURCE_ROOT/build
./example_read


SYNOPSIS:
  example_read [-out:outputfilename.txt] [-c] [-r] <file or directory names>

DESCRIPTION:
  If a file is listed, it is read as an opennurbs model file.
  If a directory is listed, all .3dm files in that directory
  are read as opennurbs model files.

  Available options:
    -out:outputfilename.txt
      The output is written to the named file.
    -chunkdump
      Does a chunk dump instead of reading the file's contents.
    -recursive
      Recursivly reads files in subdirectories.

EXAMPLE:
  example_read -out:list.txt -resursive .../example_files
  with read all the opennurbs .3dm files in the
  example_files/ directory and subdirectories.

Thank you very much for the direction.
I wanted to link the static libs to my program.
I think the main reason was the makefile in the distribution did not include the code in the android_uuid directory and instead trying to link the linux UUID library.
I linked the library libandriod_uuid.a along with the opennurbs_static.a and the program works correctly.
Thank you once again.

1 Like

Hi @menno,

Please find attached the updated Makefile. I have marked the changes… It compiles the static library and the examples without errors, even on ubuntu 20.04 LTS.
OpenNURBS_makefile_linux.zip (5.2 KB)

Hope it helps.