I am trying to get an osm.pbf file into TileMill, but terminal is throwing the error "dyld: symbol not found"
dyld: Symbol not found: __ZN4geos4geom10CoordinateD1Ev
Referenced from: /usr/local/bin/osm2pgsql
Expected in: /Library/Frameworks/GEOS.framework/Versions/3/GEOS
in /usr/local/bin/osm2pgsql
I recently reinstalled TileMill and it's now throwing me this error. I don't know how to fix it.
The error message says that your executable (osm2pgsql) isn't finding a reference to a shared library. Perhaps it's not finding the shared library itself.
From a command prompt:
1) Check which shared libraries osm2pgsql needs:
cd /usr/local/bin
ldd osm2pgsql
<= This will print a list of shared libraries, and the expected paths
2) See if your GEOS.framework directory exists, and has the (missing?) libraries
cd /Library/Frameworks/GEOS.framework/Versions/3/GEOS
ls -lR | less
3) Set LD_LIBRARY_PATH to point to your correct GEOS.framework library directory
... OR ...
Re-install GEOS.framework.
4) Here's the main page for GEOS.framework:
http://trac.osgeo.org/geos/
5) Here's additional information on $LD_LIBRARY_PATH and configuration for Linux shared libraries:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
Related
I am writing a plugin module for a larger program, written in C++. I have never written a SO library before. My module compiles and links correctly (I think) however the main program loading the SO crashes with the error symbol lookup error.
The module I am writing worked fine, until I started to try and use other libraries within it. (Specifically caffe)
There is a main program which is developed by another group
I am writing a plugin module for this program
My plugin module uses functions / code from Caffe (from the libcaffe.so file, Caffe itself is a compiled binary just to add to confusion)
The main program crashes with the following error
/path-to-binary/binary-name: symbol lookup error: ./build/libTestModule.so: undefined symbol: _ZN5caffe2db5GetDBERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
I tried adding export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib to my .bashrc.
I did this because (after some internet searching - I don't actually understand what I am doing here) I ran
nm -g libcaffe.so | grep _ZN5caffe2db5GetDBERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
in the folder /usr/lib and that symbol exists in libcaffe.so.
00000000001cbb30 T _ZN5caffe2db5GetDBERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
libcaffe.so is in /usr/lib and contains the symbol that my program cannot find.
My understanding is that (for some reason which is not known to me) I have to set LD_LIBRARY_PATH to /usr/lib so that my program can find libcaffe.co and the symbols contained within it.
However I would have assumed that since /usr/lib contains loads of "default" .so files, that this would be searched regardsless of whether LD_LIBRARY_PATH was set, ie shouldn't this directory be searched by default?
Regardless of the above question, I don't know what I should try next.
How can I get my program to find the symbol above in libcaffe.so?
CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(TestModule)
find_package(Falaise REQUIRED)
add_library(TestModule SHARED TestModule.h TestModule.cpp)
set(Caffe_INCLUDE_DIRS "/usr/include/caffe")
set(Caffe_LIBRARIES "/usr/lib/libcaffe.so")
target_link_libraries(TestModule PUBLIC Falaise::FalaiseModule)
Your libTestModule.so is, you say, dependent on libcaffe.so but you are
not linking it. This:
cmake_minimum_required(VERSION 3.3)
project(TestModule)
find_package(Falaise REQUIRED)
add_library(TestModule SHARED TestModule.h TestModule.cpp)
target_link_libraries(TestModule PUBLIC Falaise::FalaiseModule caffe)
is how you would do so.
I have modified "randomForest" packages in R.
As you know, we can customize the randomForest package by modifing the C
file.
First, i downloaded the randomForest crab file that include many c file. classTree.c, regrf.c, rf.c etc.
Second, I run the $ R CMD SHLIB rf.c in terminal on macOS. And then, i can get the "rf.so" file.
Third, I run the dyn.load("rf.so") in R. I have a following problem.
dyn.load("path/rf.so")
Error in dyn.load("path/rf.so") :
unable to load shared object 'path/rf.so':
dlopen(path/rf.so, 6): Symbol not found: _Xtranslate
Referenced from: path/rf.so
Expected in: flat namespace
in path/rf.so
how can i solve this problem?
I am faced with the exact same situation as the question raised by Gustavo in the following Link. Also, I have tried all the solutions posted in that link and other tags (such as changing library names from opus.a to libopus.a, change '\' to '/' and so on) but none of these have solved my problem. By opening the properties of the library file, these are the following things displayed:
Path: /demo/opusfile/libopusfile.a
Type: File (Static Library)
Location: U:\data\Jag\eclipse\wrksp\demo\opusfile\libopusfile.a
The error message displayed by Mingw is as follows:
15:56:57 **** Incremental Build of configuration Debug for project demo ****
Info: Internal Builder is used for build
gcc -o demo.exe "src\\demo.o" -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
collect2.exe: error: ld returned 1 exit status
collect2.exe: error: ld returned 1 exit status
Could someone please let me know what am I missing ? I am not able to resolve this issue
I think I found the solution, thanks to the answer posted in this Link. So basically to summarize the solution, I had to remove the 'lib' prefix, the '.a' suffix and the library path when I specified the libraries (-l parameters). The library path has to be specified in the -L parameter . This resolved the above problem but led to another hurdle by Mingw:
libopusfile.dll.a: could not read symbols: Archive has no index; run ranlib to add one.
I executed the 'ranlib' command in the command prompt
cmd_path> ranlib libopusfile.dll.a
, as suggested by the compiler, and this solved all my issues!
I'm building a C extension for R, this library also uses the HDF5 library.
I compiled a dynamic library (gcc flag: -fPIC -shared -Wl,-soname,libmy.so -o ../lib/libmy.so in a 'lib' directory:
$ file /path/to/my/lib/libmy.so
/path/to/my/lib/libmy.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
LD_LIBRARY_PATH is set:
$ echo $LD_LIBRARY_PATH
/path/to/hdf5/lib:/path/to/my/lib
and now when I want to load my library in R from the directory /path/to/my/src
dyn.load("libmy.so")
I get the following error:
Error in dyn.load("libmy.so") :
unable to load shared object '/path/to/my/src/libmy.so':
/path/to/my/src/libmy.so: cannot open shared object file: No such file or directory
Execution halted
If libmy.so is moved to my current working directory (I don't want this)
mv ../lib/libmy.so ./
the library seems to be loaded but R is still missing the symbols from the hdf5 library:
Error in dyn.load("libmy.so") :
unable to load shared object ' /path/to/my/src/libmy.so':
/path/to/my/src/libmy.so: undefined symbol: H5T_C_S1_g
Execution halted
I also tried load("my.so") instead of "libmy.so".
How can I load my dynamic library ?
Thanks.
EDIT: Added an example on github: https://gist.github.com/lindenb/7cd766cbb37de01f6cce
The solution was provided by John McKown on the R-Help mailing list.
I found that the dyn.load() function in R does NOT use the dlopen()
routine as I was expecting. Instead it does an open(). The open()
function needs a specific file name, including path information, in
order to open a file. It does NOT look a the LD_LIBRARY_PATH
environment variable or anything else.
Here is my code:
load.dynamic.libraries<-function(libnames)
{
for(libname in libnames)
{
found_file=libname;
for(path in unlist(strsplit(Sys.getenv("LD_LIBRARY_PATH"),":",fixed=TRUE)))
{
try_file <- paste0(path,"/",libname);
if( file.exists(try_file) )
{
found_file = try_file;
break;
}
}
write(paste("Loading :", try_file), stderr())
dyn.load(found_file);
}
}
I was originally following this tutorial: http://www.opengl-tutorial.org/miscellaneous/building-your-own-c-application/
just after about half way down, from where it says "Adding a source file in a project"
I created from this my CMakeLists.txt file as so:
cmake_minimum_required (VERSION 2.6)
project (Cube_Project)
find_package(OpenGL REQUIRED)
add_executable(Cube
main.cpp
)
include_directories(
external/glfw-2.7.6/include/
external/glm-0.9.4.0/
external/glew-1.9.0/include/
.
)
set(ALL_LIBS
${OPENGL_LIBRARY}
GLFW_276
GLEW_190
)
target_link_libraries(Cube
${ALL_LIBS}
)
but when I generate the project, I get this error:
ld: library not found for -lGLFW_276
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
I think maybe I'm not using the right names in the set(....) section? My three libs are in a folder called external, which is the top level of the project (i.e. CMakeLists is also here).
I put a zip of the project if anyone wants to take a look at the folder layout of output XCode project structure: http://heather.sh/OpenGL_Project.zip
Thanks,
The library is not in the linker's library search path.
The target_link_libraries command is is very straightforward: It simply passes on all of its arguments to the linker without bothering whether any of those libraries actually exist.
In your case, the GLFW_276 library is missing (and possibly the GLEW_190 as well, since the error occurs before that one is being processed). Make sure the library is actually installed on your system and its filename actually matches the name you use here (eg. libGLFW_276.so).
Once you verify that you have the required file, you need to make sure that the linker is able to find it. If the file is not located in one of the standard directories, use either link_directories to add its location to the search path, or find_library to obtain the full path to the library file, which can then be given to target_link_libraries.