sahib / glyr

Glyr is a music related metadata searchengine, both with commandline interface and C API
GNU Lesser General Public License v3.0
248 stars 24 forks source link

Include libraries at /opt/local/lib on OSX? #60

Closed rafi closed 9 years ago

rafi commented 9 years ago

Using OSX and Macports, how can I instruct the build to use /opt/local/lib and /opt/local/include? Tried adding INCLUDE_DIRECTORIES(/opt/local/lib /opt/local/include) in CMakeLists.txt, compilation reaches 82% but fails:

$ cmake . -DCMAKE_INSTALL_PREFIX=/opt/local
...
$ make
...
[ 78%] Building C object lib/CMakeFiles/glyr.dir/intern/photos/picsearch.c.o
[ 79%] Building C object lib/CMakeFiles/glyr.dir/intern/photos/bbcmusic.c.o
[ 80%] Building C object lib/CMakeFiles/glyr.dir/intern/guitartabs/guitaretab.c.o
[ 81%] Building C object lib/CMakeFiles/glyr.dir/intern/guitartabs/chordie_com.c.o
[ 82%] Building C object lib/CMakeFiles/glyr.dir/intern/backdrops/htbackdrops.c.o
Linking C shared library ../bin/libglyr.dylib
ld: library not found for -lgthread-2.0
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/libglyr.1.1.0.dylib] Error 1
make[1]: *** [lib/CMakeFiles/glyr.dir/all] Error 2
make: *** [all] Error 2```

I also receive this dev warning on cmake:

CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   glyr

This warning is for project developers.  Use -Wno-dev to suppress it.
sahib commented 9 years ago

You probably want to set CMAKE_INSTALL_PREFIX: cmake . -DCMAKE_INSTALL_PREFIX=/opt/local.

See here for more details. Im not yet sure if that warning you get is relevant. Could be harmless too.

rafi commented 9 years ago

That's what I was trying with. When compiling sources without cmake I normally run make CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib", but I'm not sure how to do it with cmake. I tried adding INCLUDE_DIRECTORIES(/opt/local/lib /opt/local/include) in CMakeLists.txt like I mentioned before, but still no luck, it fails at 82%..

sahib commented 9 years ago

I got you wrong then. You want to add custom cflags and ldflags. I understood initially you want to install the library into those directories.

You can try this:

cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS= "-I/opt/local/include" -DCMAKE_EXE_LINKER_FLAGS="-L/opt/local/lib"

That's not really related to glyr though...

( http://stackoverflow.com/questions/6077414/cmake-how-to-set-the-ldflags-in-cmakelists-txt )

rafi commented 9 years ago

No luck either.. same error.

RichieB2B commented 9 years ago

I was able to get passed the gthread-2.0 error on OS X using:

cmake . -DCMAKE_EXE_LINKER_FLAGS="-L/opt/local/lib" -DCMAKE_SHARED_LINKER_FLAGS="-L/opt/local/lib"
make
sudo make install
rafi commented 9 years ago

@RichieB2B thanks! Were you able to run it?

-- Install configuration: "release"
-- Installing: /opt/local/lib/pkgconfig/libglyr.pc
-- Installing: /opt/local/include/glyr/glyr.h
-- Installing: /opt/local/include/glyr/types.h
-- Installing: /opt/local/include/glyr/misc.h
-- Installing: /opt/local/include/glyr/cache.h
-- Installing: /opt/local/include/glyr/config.h
-- Installing: /opt/local/include/glyr/testing.h
-- Installing: /opt/local/lib/libglyr.1.1.0.dylib
-- Installing: /opt/local/lib/libglyr.1.dylib
-- Installing: /opt/local/lib/libglyr.dylib
-- Installing: /opt/local/bin/glyrc

$ glyrc
dyld: Library not loaded: libglyr.1.dylib
  Referenced from: /opt/local/bin/glyrc
  Reason: image not found
Trace/BPT trap: 5
RichieB2B commented 9 years ago

Yes, it seems to be working fine. Did you completely rebuild all object? Just start from scratch with a fresh git clone.

$ glyrc 
Usage: glyrc [GETTER] (options)

where [GETTER] must be one of:
 - cover
 - lyrics
 - artistphoto
...
rafi commented 9 years ago

@RichieB2B thank you so much, it works.