Undefined symbols: __dyld_func_lookup for MacOSX 64-bit linking error in 10.6.7 - undefined

I'm trying to compile a program that references __dyld_func_lookup.
Everything compiles fine, indicating include files were able to find the function reference. However, upon the final linking, I get this error:
g++ -o ../lib/macosx64/libcogmapapi.dylib -dynamiclib ./build/CogMapApi.o ./libs/cmlabs/macosx64/AIR.a ./libs/cmlabs/macosx64/CoreLibrary.a
Undefined symbols:
"__dyld_func_lookup", referenced from:
_reference in CoreLibrary.a(dlfcn_darwin.o)
_dllopen in CoreLibrary.a(dlfcn_darwin.o)
_dllopen in CoreLibrary.a(dlfcn_darwin.o)
_dllopen in CoreLibrary.a(dlfcn_darwin.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
I've tried using -undefined dynamic_lookup in the linker and it does link properly, but then at runtime I get the undefined symbol as I do actually reference __dyld_func_lookup in my code. I'm guessing I need to link to some dylib or framework, but everything I tried like System and libdl.dylib did not seem to work.
Any help would be most appreciated!

Linking dylib1.0 worked for me in same situation.

Related

Identifier "cusparseXXX" is undefined on cuda11

I'm building a package tested for CUDA 9,10 from source, trying to compile it for CUDA11.
I've already changed gencode=arch=compute_70 (was set on 30), and added
target_link_libraries(tsnecuda ${CUDA_cusparse_LIBRARY})
Unfortunately, I still get
tsne-cuda/src/util/math_utils.cu(153): error: identifier "cusparseScsr2csc" is undefined
tsne-cuda/src/util/math_utils.cu(165): error: identifier "cusparseXcsrgeamNnz" is undefined
tsne-cuda/src/util/math_utils.cu(195): error: identifier "cusparseScsrgeam" is undefined
3 errors detected in the compilation of "tsne-cuda/src/util/math_utils.cu".
CMake Error at tsnecuda_generated_math_utils.cu.o.cmake:276 (message):
Error generating file
tsne-cuda/build/CMakeFiles/tsnecuda.dir/src/util/./tsnecuda_generated_math_utils.cu.o
Is there a chance the build process somehow ignores my target_link_libraries? Should I add something else?
Undefined identifier is a compilation issue, not a linking issue.
At least part of the problem here is that CUDA deprecated and removed some functionality from cusparse, including cusparse<t>csr2csc(). The code would need to be rewritten to compile correctly under the latest versions of CUDA 11.x.
For example, for csr2csc, the call to cusparseScsr2csc might be refactored to use this function instead.
One example of deprecation/removal notice for cusparse<t>csr2csc is given here.

Undefined Symbol Error when using thrust::max_element

I am working on a CUDA C++ project that uses separable compilation, and I am having some trouble getting a thrust function to compile.
The project builds with no problem until the following function call is added.
thrust::device_ptr<float> max_int = thrust::max_element(
thrust::device_ptr<float>(dev_temp_intensity_buffer),
thrust::device_ptr<float>(dev_temp_intensity_buffer + INT_BUF_SIZE);
As said, I get the build error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol __fatbinwrap_66_tmpxft_00006db0_00000000_18_cuda_device_runtime_compute_61_cpp1_ii_8b1a5d37 referenced in function __cudaRegisterLinkedBinary_66_tmpxft_00006db0_00000000_18_cuda_device_runtime_compute_61_cpp1_ii_8b1a5d37 visualize C:\Users\13\Google Drive\WireMeshOT Rafael\CUDA\simulator\build\src\visualize_intermediate_link.obj 1
The funny thing is that this other thrust function call compiles just fine:
thrust::exclusive_scan(thrust::device_ptr<unsigned int>(dev_ray_alive),
thrust::device_ptr<unsigned int>(dev_ray_alive + NRAYS),
thrust::device_ptr<unsigned int>(dev_scanned_alive_rays));
Obs1: dev_temp_intensity_buffer is a float device pointer, and I am including thrust/extrema.h and thrust/device_ptr.h.
Obs2: I am using CMake to configure the build. The relevant CMake code excerpts are shown below.
SET(CUDA_SEPARABLE_COMPILATION ON)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -rdc=true -D_FORCE_INLINES)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=compute_52 -code=sm_52 -lcudart -lcudadevrt -lcuda)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xptxas -v)
cuda_add_executable(
project
file1.cu
...)
target_link_libraries (project glut glew)
I finally figured it out!
The linking problem was due to the fact that cudadevrt library was missing. The catch is that only adding -lcudadevrt to the CUDA_NVCC_FLAGS was not enough!
The problem goes away when linking the CUDA runtime device library to the CMake target as shown below:
target_link_libraries(project glut glew ${CUDA_cudadevrt_LIBRARY})
Obs1: the CUDA_cudadevrt_LIBRARY variable is only made available on CMake versions above 3.7.2. Adding the line cmake_minimum_required(VERSION 3.7.2) is a good idea.
Obs2: linking only to CUDA_LIBRARIES as below does solve the issue only if you are using a CMake version above 3.7.2. On lower versions this variable exist but does not contain cudadevrt library.
target_link_libraries(project glut glew ${CUDA_LIBRARIES})

Compiling my CUDA program with libraries provided in toolkit

I wrote simple CUDA c++ program simulating diffusion on 2D matrix. I got in trouble when I tried to used some of the libraries which are provided in Toolkit. I would like to replace my extremely inefficient matrix transpose kernel with something from cuBlas and also implCU with cuSolvers implementation of solving linear systems. Trouble is that I dont know how to use the functions or compile them. Its working with Makefiles on sample codes provided by Nvidia. If someone would help me, ideally showing me how are these functions supposed to be used when writing .cu files, I would be grateful.
Here is the code: http://pastebin.com/UKhJZQBz
I am on Ubuntu 16.04 and I have exported the PATH variables (so they include /usr/local/cuda-8.0/bin) as is written in official guide.
Here is the output from nvcc -I /usr/local/cuda-8.0/samples/common/inc/ difusion2d.cu
/tmp/tmpxft_00001c09_00000000-16_difusion2d.o: In function `csr_mat_norminf(int, int, int, cusparseMatDescr*, double const*, int const*, int const*)':
undefined reference to `cusparseGetMatIndexBase'
/tmp/tmpxft_00001c09_00000000-16_difusion2d.o: In function `display_matrix(int, int, int, cusparseMatDescr*, double const*, int const*, int const*)':
undefined reference to `cusparseGetMatIndexBase'
/tmp/tmpxft_00001c09_00000000-16_difusion2d.o: In function `main':
undefined reference to `cusolverDnCreate'
undefined reference to `cublasCreate_v2'
undefined reference to `cusolverDnSetStream'
undefined reference to `cublasSetStream_v2'
collect2: error: ld returned 1 exit status
You must explicitly link the cublas and cusolver libraries. Something like
nvcc -I /usr/local/cuda-8.0/samples/common/inc \
-L/path/to/CUDA/libraries difusion2d.cu -lcublas -lcusolver
should work. Depending on your installation, the -L option to provide a search path to the libraries may or may not be necessary.

Critical Error while compiling / exporting as IPA with AIR16

my application crashed while compiling with AIR16. (Flex 4.13.0-AIR 16.0)
With AIR15 it works well.
EDIT: Tried out AIR17beta. And who wonderes? It works!
First I thought, the reason might be the included ANE, but it isn't. The ANE works fine with another project.
In fact other projects also work with AIR16.
The project works fine in the Simulator without any crashes or compile errors!
We've built a lot of test-apps including the same components and libraries as in this app, but we are not able to reproduce this crash in other projects.
Any ideas?
Actual Result:
Flex 4.13.0-AIR 16.0:
Error occurred while packaging the application:
Undefined symbols for architecture armv7:
"_traits:AOTBuildOutput-0000000101_6:234::Span", referenced from:
_AOTBuildOutput-0000000101_6:9729:Edge in AOTBuildOutput-0000000101_6.o
"_traits:AOTBuildOutput-0000000101_6:234::Edge", referenced from:
_AOTBuildOutput-0000000101_6:9706:flashx.textLayout.compose::Parcel/allocateEdge
in AOTBuildOutput-0000000101_6.o
"_traits:AOTBuildOutput-0000000100_5:18::LocaleID", referenced from:
_AOTBuildOutput-0000000100_5:265:mx.resources::LocaleSorter$/sortLocalesByPreference
in AOTBuildOutput-0000000100_5.o ld: symbol(s) not found for
architecture armv7 Compilation failed while executing : ld64
Flex 4.14.0-AIR 16.0:
Error occurred while packaging the application:
Undefined symbols for architecture armv7:
"_traits:AOTBuildOutput-0000000101_6:248::Span", referenced from:
_AOTBuildOutput-0000000101_6:11261:Edge in AOTBuildOutput-0000000101_6_1.o
"_traits:AOTBuildOutput-0000000101_6:248::Edge", referenced from:
_AOTBuildOutput-0000000101_6:11238:flashx.textLayout.compose::Parcel/allocateEdge
in AOTBuildOutput-0000000101_6_1.o
"_traits:AOTBuildOutput-0000000101_6:207::CellCoords", referenced
from:
_AOTBuildOutput-0000000101_6:8073:flashx.textLayout.elements::TableElement/normalizeCells
in AOTBuildOutput-0000000101_6.o
_AOTBuildOutput-0000000101_6:8072:flashx.textLayout.elements::TableElement/getBlockedCoor
ds in AOTBuildOutput-0000000101_6.o
"_traits:AOTBuildOutput-0000000100_5:18::LocaleID", referenced from:
_AOTBuildOutput-0000000100_5:340:mx.resources::LocaleSorter$/sortLocalesByPreference
in AOTBuildOutput-0000000100_5.o ld: symbol(s) not found for
architecture armv7 Compilation failed while executing : ld64

Undefined symbol (linking .so C and Cython Code)

Since I made some progress, I changed the title and made a second edit describing my new problem. You may choose to ignore Edit1
I have been trying to run python code from C code. And for this purpose I have been using Cython.
The semantics of my system is such that there is a binary (whos source I can not access) that calls a C function defined in a file (source is accessible) and within this function I need to call python functions, do some processing and return the result to binary.
To achieve this purpose, there are two approaches that I came across:
http://docs.python.org/release/2.5.2/ext/callingPython.html ===> This approach suggests to have the python callback function passed to the C side, so that the callback is called as necessary, but this doesn't work for me as I don't have access to the binary's source (which is used to run the entire system)
https://stackoverflow.com/a/5721123/1126425 ==> I have tried this approach and I get this error when the cython function is called:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb47deb70 (LWP 2065)]
0x007fd38a in PySys_GetObject () from /usr/lib/libpython2.6.so.1.0
http://www.linuxjournal.com/article/8497?page=0,0 ==> This is in fact the basis for cython's functionality but again when I use the examples described there, I get errors similar to 2.
I have no idea how to resolve these errors. Any help would be much appreciated.
Thanks!!
Edit1:
here is a simple scenario that reflects situation:
external.c
#include <external.h>
int callback(int param1,int param2)//Function that the binary calls
{
/*SomeTasks*/
cython_func();//Function defined in the following .pyx file
/*SomeTasks*/
}
cython_file.pyx
cdef void cython_function():
print "Do Nothing!"
I am linking the shared library file created by cython with the library generated by compiling the above C code and then that library is used by the binary...
Edit2:
The segmentation fault goes away when I added Py_Initialize(); before calling cython_function(). But now I am getting the undefined symbol error as : symbol lookup error: lib_c_code.so: undefined symbol: cython_function
Here lib_c_code.so is the shared library created out of the external.c file above. I have tried including the .h file created by the cython compiler in external.c but it still didn't work out.. Here is how I am compiling lib_c_code.so:
gcc -shared -dynlib -lm -W1 -o lib_c_code.so $(OBJDIR)/*.o -lc -lm -lpy_code
and the libpy_code.so is the shared object file that was created out of the cython_file.pyx file as:
cython cython_file.pyx -o cython_file.c
gcc $(IFLAGS) -I/usr/include/python2.6 -fPIC -shared cython_file.c -lpython2.6 -lm -o libpy_code.so
Also, I can see the symbol cython_function in the lib_c_code.so file when I do : nm -g lib_c_code.so..
Any ideas please?
I have to guess here that there's a callback registration function to which you can pass the function pointer, in which case you can simply forego the C file and define a cdef function directly in your Cython code, and pass that with the callback registration function. Use with gil in case you manipulate any Python objects in it.
cdef extern from "external.h":
ctypedef int (*Cb_Func)(int param1, int param2)
void register_callback(Cb_Func func)
cdef int my_callback(int param1,int param2) with gil:
<implementation>
register_callback(my_callback)
This is also explained in the Cython user manual here: http://docs.cython.org/src/userguide/external_C_code.html