I'm new to libsvm and matlab. I have downloaded libsvm 3.17 from the web site and trained my dataset using Matlab. I wanted to save the file and I used svm_savemodel.c which refused to compile in matlab. This is the message that I get
mex svm_savemodel.c
Creating library C:\Users\mark\AppData\Local\Temp\mex_zcr67j\templib.x and object C:\Users\mark\AppData\Local\Temp\mex_zcr67j\templib.exp
svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_free_and_destroy_model referenced in function _mexFunction
svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_save_model referenced in function _mexFunction
svm_savemodel.obj : error LNK2019: unresolved external symbol _matlab_matrix_to_model referenced in function _mexFunction
svm_savemodel.mexw32 : fatal error LNK1120: 3 unresolved externals
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'svm_savemodel.mexw32' failed.
Error using mex (line 206)
Unable to complete successfully.
So can anyone help me to solve this?
I have included svm.h, mex.h, svm_model_matlab.h but it refused....
This is what I have done
>> mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2011b/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011b\sys\lcc
[2] Microsoft Visual C++ 2010 in C:\Program Files\Microsoft Visual Studio 10.0
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
Trying to update options file: C:\Users\michael\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2011b\bin\win32\mexopts\msvc100opts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
**************************************************************************
>> cd('C:\libsvm-3.17\libsvm-3.17\matlab');
>> make
>> mex svm_savemodel.c
Creating library C:\Users\michael\AppData\Local\Temp\mex_coX2K1\templib.x and object C:\Users\michael\AppData\Local\Temp\mex_coX2K1\templib.exp
svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_free_and_destroy_model referenced in function _mexFunction
svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_save_model referenced in function _mexFunction
svm_savemodel.obj : error LNK2019: unresolved external symbol _matlab_matrix_to_model referenced in function _mexFunction
svm_savemodel.mexw32 : fatal error LNK1120: 3 unresolved externals
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'svm_savemodel.mexw32' failed.
Error using mex (line 206)
Unable to complete successfully.
>>
add this to your make.m file (you can add them to both if and else part):
mex CFLAGS="$CFLAGS -std=c99" -largeArrayDims svm_savemodel.c ../svm.cpp svm_model_matlab.c
Related
While building my project, I get the same issue, solved in this links:
SOIL not linking correctly,
SOIL set-up in Visual Studio 2010
I tried every suggested solution:
build the VC8 and VC9 libraries to get the SOIL.lib (I'm using VS 2013)
linked the libraries (Linker - Additional Dependencies)
renamed the libSoil.a to SOIL.lib
but still having the same errors:
1>libSOIL.a(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer
1>libSOIL.a(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2
Any ideas , other solutions?
I can't seem to get a very simple program to compile in Visual Studio 2013. My goal is to incorporate UHD into a C++ program (UHD Driver and Libraries for Windows). I downloaded and installed the Windows UHD package.Since the library also depends on Boost, I also downloaded the appropriate Boost library. After that, I wrote a quick test program in Visual Studio 2013:
#include "stdafx.h"
#include <iostream>
#include <uhd\usrp\multi_usrp.hpp>
#include <uhd\types\device_addr.hpp>
using namespace uhd;
int main(void)
{
device_addr_t hint;
device_addrs_t dev_addrs = device::find(hint);
system("pause");
return 0;
}
In case anyone is interested, this program should locate any USRPs attached to a host PC. I defined the appropriate include paths in Visual Studio: . .
To be clear, I included two paths to the header files:
C:\Program Files (x86)\UHD\include and C:\Program Files (x86)\boost_1_55_0
and one path to the library:
C:\Program Files (x86)\UHD\lib
When I wrote the above program, Visual Studio recognized the additional include files, recognized device_addr_t as a typedef, and didn't throw any errors. However, when I built the program, I received these errors:
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::vector<class uhd::device_addr_t,class std::allocator<class uhd::device_addr_t> > __cdecl uhd::device::find(class uhd::device_addr_t const &)" (__imp_?find#device#uhd##SA?AV?$vector#Vdevice_addr_t#uhd##V?$allocator#Vdevice_addr_t#uhd###std###std##ABVdevice_addr_t#2##Z) referenced in function _main C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::~device_addr_t(void)" (__imp_??1device_addr_t#uhd##QAE#XZ) referenced in function "public: void * __thiscall uhd::device_addr_t::`scalar deleting destructor'(unsigned int)" (??_Gdevice_addr_t#uhd##QAEPAXI#Z) C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::device_addr_t(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0device_addr_t#uhd##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function _main C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 4 error LNK1120: 3 unresolved externals C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\Debug\uhd_test.exe uhd_test
I've encountered these errors before in other programs, but I was able to resolve them relatively easily; either I would misspell a crucial include, or there would be an issue with a template class. However, in this instance, I can't seem to resolve the issue.
Any constructive input would be appreciated.
NOTE: In addition to defining the library directory path, I've explicitly added the UHD library, and I receive the same errors.
I got your example working. Here's the software versions I used since you didn't mention much in your description:
Microsoft Visual Studio 2013
VC++ Redistributable Package for VS2013 (vcredist_x86)
UHD 003.007.002, VS2013, Win32
Boost 1.56, lib32-msvc-12.0 binary package
Here are the project configuration properties you need to set in your VS2013 applications:
C/C++ -> General -> Additional Include Directories
C:\local\boost_1_56_0
C:\Program Files (x86)\uhd\include
Linker -> General -> Additional Library Directories
C:\local\boost_1_56_0\lib32-msvc-12.0
C:\Program Files (x86)\uhd\lib
Linker -> Input -> Additional Dependencies
uhd.lib
I think the last step is what's tripping you up, good luck!
I followed exactly what David Greene said, and I ended up with the same errors. Eventually I figured out that I had downloaded the 64-bit UHD, but I was using Visual Studio 2013 Express, which was a 32-bit compiler. Downloading the 32-bit version of UHD for Visual Studio 2013 solved the problem. For anyone else having this problem, double check that the compiler matches which version of UHD you install.
I'm trying to create a GLFW project, but I'm getting LNK2019 errors with the basic setup.
I've downloaded the latest binary (glfw-3.0.bin.WIN32.zip) to a folder.
I've created a new, empty console project.
Within VC++ Directories, I've added the following line to include directories:
C:\C++Libraries\glfw-3.0.bin.WIN32\include
I've added the following line to the Library Directories:
C:\C++Libraries\glfw-3.0.bin.WIN32\lib-msvc110
I've linked the following libraries:
opengl32.lib, glfw3.lib, glfw3dll.lib
From the latest tutorial, I paste into my project (no visible syntax errors) to test, but I get four LNK2019 errors after trying to run it.
Here are the errors:
Error 2 error LNK2019: unresolved external symbol __imp__joyGetPosEx#8
referenced in function __glfwPlatformGetJoystickAxes
c:\Users\Spicy Weenie\documents\visual studio 2012\
Projects\Beta\Beta\glfw3.lib(win32_joystick.obj)
Error 3 error LNK2019: unresolved external symbol __imp__joyGetDevCapsW#12
referenced in function __glfwPlatformGetJoystickAxes
c:\Users\Spicy Weenie\documents\visual studio
2012\Projects\Beta\Beta\glfw3.lib(win32_joystick.obj)
Error 4 error LNK2019: unresolved external symbol __imp__joyGetPos#8
referenced in function __glfwPlatformJoystickPresent
c:\Users\Spicy Weenie\documents\visual studio
2012\Projects\Beta\Beta\glfw3.lib(win32_joystick.obj)
Error 1 error LNK2019: unresolved external symbol __imp__timeGetTime#0
referenced in function __glfwInitTimer c:\Users\Spicy Weenie\documents\visual
studio 2012\Projects\Beta\Beta\glfw3.lib(win32_time.obj)
You need to link in at least winmm.lib for timeGetTime. The joystick code is probably in there to.
I am trying to run mixed integer quadratic programming by calling Cplex (122version) from Matlab using Mex function. When I try in matlab : mex miqp_cplex.c, following type errors occurred.
Creating library C:\Users\maskamal\AppData\Local\Temp\mex_3XVWAG\templib.x and object C:\Users\maskamal\AppData\Local\Temp\mex_3XVWAG\templib.exp
miqp_cplex.obj : error LNK2019: unresolved external symbol __imp_CPXcloseCPLEX referenced in function miqp
miqp_cplex.obj : error LNK2019: unresolved external symbol __imp_CPXfreeprob referenced in function miqp
miqp_cplex.obj : error LNK2019: unresolved external symbol __imp_CPXgetmipitcnt referenced in function miqp
miqp_cplex.mexw64 : fatal error LNK1120: 21 unresolved externals
C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Link of 'miqp_cplex.mexw64' failed.
Since it fail to locate "ilcplex\cplex.h", I add full path
include "C:\ILOG\CPLEX_Studio_AcademicResearch122\cplex\include\ilcplex\cplex.h" and I guess problem is related to cplex.h and linking with library.
Any hints to solve my problem are welcomed.
I could solve it partly. I could compile by adding the path of library with mex command. However, when I run the mex file: miqp_cplex it says:
Invalid MEX-file 'C:\Users\maskamal\Documents\MATLAB\MexCplex80\miqp_cplex.mexw64': 指定されたモジュールが見つかりません。(translation from japanese: indicated module is not found)
My Matlab R2011a and Cplex122
I'm trying to link my project with fftw and so far, I've gotten it to compile, but not link. As the site said, I generated all the .lib files (even though I'm only using double precision), and copied them to C:\Program Files\Microsoft Visual Studio 9.0\VC\lib, the .h file to C:\Program Files\Microsoft Visual Studio 9.0\VC\include and the .dll to C:\windows\system32.
I've copied the tutorial program, and the exact error I am getting is:
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_free referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_destroy_plan referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_execute referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_plan_dft_1d referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_malloc referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
So, what could be wrong with my project setup? Thanks!
My case
Using FFTW in Visual Studio 2010
Precompiled FFTW 3.3.1 Windows DLLs install using fftw-3.2.1-dll.zip, on my Windows XP machine.
Open cmd window and go to lib.exe folder C:\Program Files\Microsoft Visual Studio 10.0\VC\bin>
Type lib /def:libfftw3-3.def
Type lib /def:libfftw3f-3.def
Type lib /def:libfftw3l-3.def
If you have a error on command, copy any mspdb80.dll or mspdb100.dll file to in bin directory.
You will get 6 files
libfftw3-3.exp, libfftw3-3.lib, libfftw3f-3.exp, libfftw3f-3.lib,
libfftw3l-3.exp and libfftw3l-3.lib
and copy it to programming directory.
Delete all mspdb80.dll or mspdb100.dll file from bin directory.
Closed Project and open again and rebuild it again.
Have you actually linked against the library in the project you're building?
Project -> Properties -> Linker -> Input -> Additional dependencies
You need to add the library's filename to that field.
Assuming you've actually linked your project against the lib and it doesn't work, use /verbose:lib and paste the output of that and the output of
dumpbin /exports fftw.lib | findstr fftw_free
I had similar problem. What helped was compiling the fftw libs with this help Compiling FFTW source in Visual studio. Actually more closely the problem was compiling my application Win 32 and trying to use x64 -libraries. So make sure the platform is same.