I am compiling a dll which goes just fine unless I use the -deviceemu mode.
In this case I get several of the following linking errors:
CUDAKernel_ColourHist.obj : error LNK2019: unresolved external symbol
___cudaMutexOperation#4 referenced in function ___uAtomicAdd
1>CUDAKernel_1.obj : error LNK2001:
unresolved external symbol
___cudaMutexOperation#4 1>CUDAKernel_2.obj : error LNK2001:
unresolved external symbol
___cudaMutexOperation#4
Which led me to believe perhaps I wasn't linking the correct files, but I believe I am. I am using Visual Studio and any help woud be appreciated.
Fixed, I was using an older version of the libraries, linking with the newer libraries fixed the problem.
Related
PyTorch extensions seem to be experimental.
There is a work around described here:
https://pytorch.org/docs/stable/notes/windows.html#extension
I converted to cpp and added the libs as described:
from torch.utils.ffi import create_extension
ffi = create_extension(
'_ext.nms',
headers=headers,
sources=sources,
define_macros=defines,
relative_to=__file__,
with_cuda=with_cuda,
extra_objects=extra_objects,
libraries=["cudart","_C"]
)
It compiles ok, however, I am still getting a lot of unresolved external symbols from the linker:
nms.obj : error LNK2001: unresolved external symbol __imp_THFloatTensor_data
nms.obj : error LNK2001: unresolved external symbol __imp_THByteTensor_fill
nms.obj : error LNK2001: unresolved external symbol __imp_THExpm1
[...]
The _C.lib does not seem to contain the TH... symbols (checked with dumpbin _C.lib /ALL), and I can't find any libTH.lib or similar to link.
Where do I find the right library?
Is there any chance to do this on Windows?
As I need to link to static C runtimes I decided to build all as static librarys in question with the same version of Visual Studio (2013) using the same Platform Toolset and Runtime libraries Multi-Threaded /MT
I am trying to get my application to link to a 3rd party game engine. This engine is built on top of libpng and zlib. libpng is also built on top of zlib.
So I build zlib from scratch into a static library.
I then build libpng and point it to the zlib as an additional dependency so zlib gets linked in to my libpng static library.
I then build my game engine linking to both libpng and zlib as additional dependencies. The linker removes the second zlib definition. So far all builds fine.
I then link my application just to my game engine static library. I get linker errors like:
2>libOxygine-vc120-mt-gd.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflate
2>libOxygine-vc120-mt-gd.lib(pngrutil.obj) : error LNK2001: unresolved external symbol _inflate
2>libOxygine-vc120-mt-gd.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflateEnd
2>libOxygine-vc120-mt-gd.lib(pngread.obj) : error LNK2001: unresolved external symbol _inflateEnd
2>libOxygine-vc120-mt-gd.lib(unzip.obj) : error LNK2001: unresolved external symbol _crc32
2>libOxygine-vc120-mt-gd.lib(png.obj) : error LNK2001: unresolved external symbol _crc32
2>libOxygine-vc120-mt-gd.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflateInit2_
2>libOxygine-vc120-mt-gd.lib(png.obj) : error LNK2001: unresolved external symbol _adler32
2>libOxygine-vc120-mt-gd.lib(png.obj) : error LNK2001: unresolved external symbol _inflateReset
2>libOxygine-vc120-mt-gd.lib(pngrutil.obj) : error LNK2001: unresolved external symbol _inflateInit_
2>libOxygine-vc120-mt-gd.lib(pngwrite.obj) : error LNK2001: unresolved external symbol _deflateEnd
2>libOxygine-vc120-mt-gd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflateReset
2>libOxygine-vc120-mt-gd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflateInit2_
2>libOxygine-vc120-mt-gd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflate
It seems to be having a problem finding zlib but this has been linked into libpng, which in turn was linked into the game library libOxygine.
My application itself is not directly dependant on both zlib and libpng so I dont really want to have to link to them directly from my application as it should be all taken care of inside my game engine library libOxygine.
Thanks
If you used .vcxproj project from zlib package, it contains some bugs.
here is instruction for fixing them (i used zlibvc, not zlibstat):
http://www.tannerhelland.com/5076/compile-zlib-winapi-wapi-stdcall/
For fixing the unresolved symbols problem, open zlib project preferences,
then go to Configuration Properties -> C/C++ -> Preprocessor, and in the Preprocessor Definitions line remove “ZLIB_WINAPI;” (don’t forget to remove the trailing semicolon).
libpng depends upon zlib, so you must link libpng first, then zlib. From your error messages it appears that you have them reversed. For example, if you are using gcc to build and link, you need "-lpng -lz" on the commandline, not "-lz ... -lpng".
I'm trying to run a program based on tesseract and opencv on Visual Studio 2013. I have a x64 bit machine and the problem is when I run it under Win32 I got only opencv linking errors, however under x64 I got tesseract linking errors.
Here are some errors screenshots :
Tesseract Errors :
error LNK2001: unresolved external symbol pixDestroy
error LNK2001: unresolved external symbol pixReadTesseract
error LNK1120: 7 unresolved externals
Opencv Errors :
error LNK2001: unresolved external symbol _cvLoadImage
error LNK2001: unresolved external symbol _cvCreateImage
error LNK2001: unresolved external symbol _cvSaveImage
error LNK2001: unresolved external symbol _cvReleaseImage
error LNK1120: 4 unresolved externals
Thank you guys :-)
Your problem appears to be that you have 32bit build of Tesseract and 64bit build of OpenCV, and trying to use them both in the same program. That will not work -- you either need all 64bit libraries for a 64bit application, or all 32bit libraries for a 32bit application.
If you want to stick with OpenCV 3.1 (since the standard distribution package doesn't seem to contain 32bit binaries), then you have to go and build one of the libraries yourself. The older versions still had them.
Another option is to download this nuget package along with the associated redistributables package. Since the files are just ZIP files with a different extension, it is possible to extract all the headers, import libraries and DLLs manually.
I've been struggling to compile my Visual C++ 2010 project with dependency of Zlib. I've got source code that worked on Linux and Mac OS X. Here's, where I have linker errors:
error LNK2019: unresolved external symbol _inflate#8 referenced in function...
error LNK2019: unresolved external symbol _inflateInit2_#16 referenced in function...
error LNK2019: unresolved external symbol _deflate#8 referenced in function...
error LNK2019: unresolved external symbol _deflateInit2_#32 referenced in function...
I've been finding solution for few days now, trying compiling Zlib different ways, but it is clear that I've missed something. Very similar question has been answered here, but not clearly enough for amateur like me. I would need step-by-step guide how to get it to work.
Thank you in advance.
If you have static libraries after building the Zlib, point them in your project at this location.Project properties -> Linker -> Input -> Additional dependencies. Give the absolute path.
I built ffmpeg 1.2.1 as a static lib - x64, debug. And I tried to open one of my older projects that links against it. After modifying some changed APIs and similar in my source, it compiled fine, but I have major problems with linking.
EDITED: the complete latest build output:
1>libavformat.a(mov.o) : error LNK2019: unresolved external symbol __imp__gmtime64 referenced in function mov_read_mvhd
1>libavutil.a(parseutils.o) : error LNK2001: unresolved external symbol __imp__gmtime64
1>libavformat.a(os_support.o) : error LNK2019: unresolved external symbol __imp__wsopen referenced in function ff_win32_open
1>libavcodec.a(pthread.o) : error LNK2019: unresolved external symbol __imp__beginthreadex referenced in function ff_thread_init
1>libavcodec.a(frame_thread_encoder.o) : error LNK2001: unresolved external symbol __imp__beginthreadex
1>libavutil.a(parseutils.o) : error LNK2019: unresolved external symbol __imp__localtime64 referenced in function av_parse_time
1>libavutil.a(parseutils.o) : error LNK2019: unresolved external symbol __imp__time64 referenced in function av_parse_time
1>libavutil.a(parseutils.o) : error LNK2019: unresolved external symbol __imp__mktime64 referenced in function av_parse_time
1>libmingwex.a(lib64_libmingwex_a-mingw_output_format.o) : error LNK2019: unresolved external symbol __mingw_get_msvcrt_handle referenced in function __mingw_set_output_format
1>libmingwex.a(lib64_libmingwex_a-mingw_get_codepage.o) : error LNK2001: unresolved external symbol __mingw_get_msvcrt_handle
What am I doing wrong? What am I missing here?
Does ffmpeg even work today on Windows platform as a static lib, or it becomes less functional on Windows with each new version?
First 8 errors could be solved by manually inserting
#define _CRTIMP
in some files. This will prevent incorrect use of declspec(__dllimport). We are building a static lib, not a DLL, so it shouldn't be there. I also tried using --extra-cflags='-D_CRTIMP' while running configure before building ffmpeg, but it brakes the build totally. So, manual way is the only way.
The last 2 errors are total bitch:
libmingwex.a(lib64_libmingwex_a-mingw_output_format.o) : error LNK2019: unresolved external symbol __mingw_get_msvcrt_handle referenced in function __mingw_set_output_format
1>libmingwex.a(lib64_libmingwex_a-mingw_get_codepage.o) : error LNK2001: unresolved external symbol __mingw_get_msvcrt_handle
I found these symbols in libmingw32.a (if I remember correctly). But, when I link it, I have conflicts with LIBCMTD.lib. Removing the LIBCMTD.lib creates tons of unresolved externals.So, I would say that today we are not able to build ffmpeg as static x64 lib on Windows. It was in a way expected, because each new version was less Windows friendly.