deeplearningais / CUV

Matrix library for CUDA in C++ and Python
www.ais.uni-bonn.de
196 stars 48 forks source link

Compile with Visual Studio 2015 on Windows 10 #13

Open ifenglin opened 7 years ago

ifenglin commented 7 years ago

Hello, I understand this project has probably only been tested on Linux, but all the dependent libraries are also available on Windows. My environment is Visual Studio 2015 Win64 on Windows 10. I apply it to CMake commands and create VC projects. I build this for CURFIL and therefore I build only an extraction of ndarray. I can build the ndarray.lib successfully, but I cannot resolve the numerous linking errors while building allocators_test and ndarray_test of LNK2019:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol "public: __cdecl cuv::pooled_cuda_allocator::pooled_cuda_allocator(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0pooled_cuda_allocator@cuv@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "void __cdecl allocators_test::test_pooled_allocator<struct cuv::dev_memory_space>(void)" (??$test_pooled_allocator@Udev_memory_space@cuv@@@allocators_test@@YAXXZ) allocators_test D:\ndarray-master\build8\src\tests\allocators_test.obj  1   

I don't think it is an OS-related issue, rather an incorrect setup for the linker. Here is the list of input for the linker:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cudart_static.lib
C:\Boost\lib\vc14\x64\libboost_unit_test_framework-vc140-mt-gd-1_64.lib
C:\Boost\lib\vc14\x64\libboost_serialization-vc140-mt-gd-1_64.lib
C:\Boost\lib\vc14\x64\libboost_system-vc140-mt-gd-1_64.lib
C:\Program Files\Intel\TBB\lib\intel64\vc14\tbb_debug.lib
C:\Program Files\Intel\TBB\lib\intel64\vc14\tbbmalloc.lib
..\cuv\Debug\ndarray.lib

I have been stuck for more than a week. I'd heartily appreciate it f anyone has an idea about this or has more knowledge about linking to share.

Cheers, ifeng

temporaer commented 7 years ago

hey ifeng, my knowledge of VS is limited, but on linux the order of the linker arguments is from specific to general, which would be roughly the opposite of what you pasted.

ifenglin commented 7 years ago

Thanks for the reply, temporaer. I inverted the order of linker input, but it seemed in vain.

The edited linker arguments: /OUT:"D:\ndarray-master\build8\src\tests\Debug\allocators_test.exe" /MANIFEST /NXCOMPAT /PDB:"D:/ndarray-master/build8/src/tests/Debug/allocators_test.pdb" /DYNAMICBASE "..\cuv\Debug\ndarray.lib" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cudart_static.lib" "C:\Boost\lib\vc14\x64\libboost_unit_test_framework-vc140-mt-gd-1_64.lib" "C:\Boost\lib\vc14\x64\libboost_serialization-vc140-mt-gd-1_64.lib" "C:\Boost\lib\vc14\x64\libboost_system-vc140-mt-gd-1_64.lib" "C:\Program Files\Intel\TBB\lib\intel64\vc14\tbbmalloc.lib" "C:\Program Files\Intel\TBB\lib\intel64\vc14\tbb_debug.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"D:/ndarray-master/build8/src/tests/Debug/allocators_test.lib" /DEBUG /MACHINE:X64 /INCREMENTAL /PGD:"D:\ndarray-master\build8\src\tests\Debug\allocators_test.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"allocators_test.dir\Debug\allocators_test.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:/Boost/lib/vc14/x64" /LIBPATH:"C:/Boost/lib/vc14/x64/Debug" /TLBID:1