I am writing a BCI game application in VC++ and require to implement Common Spatial Pattern Filtering (CSP) for feature extraction. Due to the hefty coding involved, I prefer to use an existing CSP Matlab function that I have. I followed the steps as given in here. However, I am getting the following Link error message:
1>------ Build started: Project: Test4, Configuration: Debug Win32 ------
1>test.obj : error LNK2019: unresolved external symbol _mxGetScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxDestroyArray referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxCreateDoubleScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engEvalString referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOpen referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engClose referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engGetVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engPutVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOutputBuffer referenced in function _main
1>D:\Test4\Debug\Test4.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Could anyone please help me fix the problem? Any comments would be appreciated. Thanks in advance.
As I said in the referred post, you have to keep the platforms consistent:
The platforms of MATLAB and VC++ compile platform must be the same, i.e. Win32/x86 VC++ compile platform can only use x86 MATLAB and x64 VC++ compile platform can only use x64 MATLAB.
You're using MATLAB x64, thus you have to build your VC project in x64 too.
Related
I'm trying to run a program with GLFW in C++. I'm using visual studios 2019 on a windows 10 computer. I put the .h's and the .lib's in the proper folders and linked to them in the project settings. I'm running a minimal GLFW program I got off the internet. When I run it I get the following error:
1>------ Build started: Project: Riemannian, Configuration: Debug Win32 ------
1>Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwMakeContextCurrent referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>C:\Users\Aaron\source\repos\Riemannian\Debug\Riemannian.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Riemannian.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried adding glfw3.dll to system32, but that didn't change anything. (side note, GLFW came with a file glfw3dll.lib. Is that just a .lib file that serves the same purpose as glfw3.dll?) Next I tried linking to opengl32.lib in my project settings. This got rid of the first error, the one with the __imp__ prefix. After that there were only 7 unresolved external symbols. My project type is "Application (.exe)" if that's relevant. I'm out of ideas and tired of googling, does anyone know what to do?
On a broader note, I have wasted so many hours trying to get libraries to work in Python, Java, and C++. I am incredibly frustrated and I wish someone could just explain to me how libraries work once and for all so that next time I have a problem I won't be completely lost.
If all this setup is too complicated, you can also just take the Glitter project as a base. It takes care of all the boilerplate and just lets you get on with writing OpenGL. As a bonus, it is based on the cross-platform CMake build tool so your project should be easy to port to other operating systems.
I try to compile VC++ application and get the error message as below. Is there anyone who know what the library I may be missing? Any advice & suggestion are appreciated.
My Environment:
VC++ 2010
zlib-1.2.8
boost_1_57_0
icu
1>------ Build started: Project: paloserver, Configuration: Debug Win32 ------
1> Creating library C:/Users/a992788/Virtual Machines/Documents/Application/Palo/Palo 3.x Source Code/palo-code-546/molap/server/5.1/SourceCode/Debug/paloserver.lib and object C:/Users/a992788/Virtual Machines/Documents/Application/Palo/Palo 3.x Source Code/palo-code-546/molap/server/5.1/SourceCode/Debug/paloserver.exp
1>unzip.obj : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function _unzOpenCurrentFile3
1>unzip.obj : error LNK2019: unresolved external symbol _inflate referenced in function _unzReadCurrentFile
1>unzip.obj : error LNK2019: unresolved external symbol _crc32 referenced in function _unzReadCurrentFile
1>zip.obj : error LNK2001: unresolved external symbol _crc32
1>unzip.obj : error LNK2019: unresolved external symbol _inflateEnd referenced in function _unzCloseCurrentFile
1>zip.obj : error LNK2019: unresolved external symbol _get_crc_table referenced in function _zipOpenNewFileInZip4_64
1>zip.obj : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function _zipOpenNewFileInZip4_64
1>zip.obj : error LNK2019: unresolved external symbol _deflate referenced in function _zipWriteInFileInZip
1>zip.obj : error LNK2019: unresolved external symbol _deflateEnd referenced in function _zipCloseFileInZipRaw64
1>C:\Users\a992788\Virtual Machines\Documents\Application\Palo\Palo 3.x Source Code\palo-code-546\molap\server\5.1\SourceCode\Debug\paloserver.dll : fatal error LNK1120: 8 unresolved externals
Add reference to the zdll.lib in your source.
#pragma comment (lib, "zdll.lib")
This question already has answers here:
Error in Release mode but not in Build mode
(3 answers)
Closed 8 years ago.
What is follow errors in opencv 247 and visual 2012?
------ Rebuild All started: Project: ConsoleApplication8, Configuration: Debug Win32 ------
Source.cpp
Source.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _main
Source.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _main
Source.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _main
Source.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _main
Source.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _main
Source.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main
C:\Users\a\documents\visual studio 2012\Projects\ConsoleApplication8\Debug\ConsoleApplication8.exe : fatal error LNK1120: 6 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
you will have to link against opencv_core247d.lib and opencv_highgui247d.lib (without the d for release)
I am having problem figure out how to use libusb, I put "libusb-1.0.18-rc1\libusb"
in include directories (using Visua Studio), but it doesn't work.
Can anyone enlighten me. Thanks a lot!
error message:
1>test.obj : error LNK2019: unresolved external symbol _libusb_exit#4 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_close#4 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_release_interface#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_bulk_transfer#24 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_claim_interface#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_detach_kernel_driver#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_kernel_driver_active#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_free_device_list#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_open_device_with_vid_pid#12 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_get_device_list#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_set_debug#8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_init#4 referenced in function _main
If you havne't done so already you will need to build the libraries you will be linking to, they are located in \libusb-1.0.18-rc1\msvc. There are multiple projects there depending on your Visual Studio version and whether you want a DLL or a static LIB file.
In either case you will need to right click on your project, then under Configuration Properties -> Linker -> Input -> Additional Dependencies add a reference to the LIB file you created. If you are linking to the static LIB file you're done, it will build the code in to your executable. If you're linking to the LIB file for the DLL make sure the DLL is available in your execution path. In either case this should resolve your unresolved externals.
I think you must take the 32-Bit Version of the libusb-Library/DLL and ensure 32 Bit Compile at Project Properies. That solved my Problem with LNK2019.
I've been trying to use the CUDA driver API to load a .ptx file and a function from it with this code:
CUdevice device;
cuDeviceGet(&device,0);
CUcontext ctx;
cuCtxCreate(&ctx,0,device);
CUmodule mod;
cuModuleLoad(&mod,"kernel.ptx");
CUfunction func;
cuModuleGetFunction(&func,mod,"kernel");
CUdeviceptr ints;
cuMemAlloc(&ints,(sizeof(int)*30));
However at compile time I get these errors:
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuDeviceGet#8 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuCtxCreate_v2#12 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuModuleLoad#8 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuModuleGetFunction#12 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemAlloc_v2#8 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemcpyHtoD_v2#12 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemcpyDtoH_v2#12 referenced in function _main
1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuLaunchKernel#44 referenced in function _main
I created a new CUDA 5.5 project in VS2012 and typed this directly into the generated .cu file however at compile time I got these errors. If I do a test that doesn't use the driver api I don't get any errors!
Those errors occur when you are not linking against cuda.lib.
For those who does not know how to add cuda.lib into linking process like me (using VS2017):
Right click on the project, goto Properties at the bottom of the menu
Goto Linker-->Input
In Additional Dependencies, make sure that cuda.lib is there. In my case, this solved the 2019 link error.
Besides, if you click on the edit item in the drop menu, there is a Macros button that you can click and view all pre-defined Macros in your VS project.