Author Topic: unresolved symbol errors while linking vamp plugin  (Read 21826 times)

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
unresolved symbol errors while linking vamp plugin
« on: March 03, 2009, 16:35:01 »
hi.

i am making a vamp plugin and uses the plugin wrapper of aubio (pitchdetection).

i already linked the static library of vamp-aubio but i got this error when linking.

may i ask what is the runtime library used in building vamp-aubio static library coz i am encountering unresolved symbol errors. one of the possible cause is the compatibility of the runtime library use.

this is the error--

>vamp-aubio.lib(vamp-aubio.obj) : error LNK2019: unresolved external symbol __imp____lc_codepage referenced in function _VAMP-AUBIO_DllMain@12


hope anybody could help me with this problem. please..

thanks...

hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #1 on: March 06, 2009, 10:45:46 »
It's not quite clear to me where you got the vamp-aubio.lib static library from?  There isn't a static library included in the vamp-aubio distribution.

I'm far from expert on the details of Windows libraries and linkers -- and this is clearly a Windows-specific problem.  But I think this sort of error, in which you have an unresolved symbol with an "__imp__" prefix, means that you have code that was compiled specifically to be used in a DLL, where the symbols have been declared with __declspec(dllimport).  I don't think you can link such code statically without some further trickery.  Generally, to produce a static library, you would have to compile the code in a different way using some pre-processor symbol that tells the compiler not to generate the DLL import prefixes.  Exactly how to do this, usually, depends on the build system for the library.

I'm sorry I don't have any specific suggestions.  You might get more help if you ask this sort of question on a site with a higher proportion of Windows experts (such as stackoverflow.com), although it would help if you can express the problem in such a way that people can answer it without knowing too much about the specific libraries you are using.

Alternatively, rather than trying to link against a static library, you might find it simpler to add the source files to your project and compile them all together.

(The specific symbol that you have -- lc_codepage -- comes from the locale library, and possibly originates with one of the Unix-Windows cross compiler support libraries from MinGW.)


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #2 on: March 06, 2009, 13:14:35 »
hi,

thanks for the reply.

i got vamp-aubio.lib for a .dll to .lib converter.

before linking this library, i got the same unresolved errors referenced from the functions in pitchdetection of aubio.



Alternatively, rather than trying to link against a static library, you might find it simpler to add the source files to your project and compile them all together.



I put the source files of aubio library in my project but still i got unresolved symbol errors.

thanks.

hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #3 on: March 06, 2009, 13:46:30 »
I put the source files of aubio library in my project but still i got unresolved symbol errors.

Which symbols were unresolved then?  Were they also __imp__ symbols, or something different?


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #4 on: March 06, 2009, 14:11:37 »

It's different.

These are the errors.

VocalRangeAnalyzerPlugin.obj : error LNK2019: unresolved external symbol _del_fvec referenced in function "public: virtual __thiscall VocalRangeAnalyzerPlugin::~VocalRangeAnalyzerPlugin(void)" (??1VocalRangeAnalyzerPlugin@@UAE@XZ)

VocalRangeAnalyzerPlugin.obj : error LNK2019: unresolved external symbol _del_aubio_pitchdetection referenced in function "public: virtual __thiscall VocalRangeAnalyzerPlugin::~VocalRangeAnalyzerPlugin(void)" (??1VocalRangeAnalyzerPlugin@@UAE@XZ)

...that's just 2 out of the 6 unresolved externals.


cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #5 on: March 06, 2009, 14:23:05 »

That's strange, these are plain C functions that are defined in the aubio source files (del_fvec is defined in sample.c, declared in sample.h, etc).

I can't see, at first reading, what could cause this.  Hmm.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #6 on: March 06, 2009, 14:34:54 »

I really badly need to solve this stuff.

I just did this steps in doing this project.

--I used VampExamplePlugins.vcproj to start. I added up VocalRangeAnalyzerPlugin.cpp and VocalRangeAnalyzerPlugin.h to the project.
--Then, i copied some codes from Pitchdetection.cpp file of Aubio. Then I added the aubio library files and put it on a folder called aubio.
--Then compile it and got that errors.
--Searched on Google about these errors and says that I need to link libraries. Got also an idea how to convert a .dll file into a .lib static library using the converter.
--Using vamp-aubio.dll, I got vamp-aubio.lib, linked it through project properties. Got that error above.

Did I miss something?

Thanks.

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #7 on: March 06, 2009, 16:49:59 »
--Then, i copied some codes from Pitchdetection.cpp file of Aubio. Then I added the aubio library files and put it on a folder called aubio.
--Then compile it and got that errors.

You're quite sure that the Aubio library files were included in the build and link, at this point?

The most obvious reason why you would have symbols such as _del_fvec undefined in the link would be simply that the file that defines them (e.g. sample.c, in this case) was not compiled and/or linked with the build.  That is, either sample.c was not compiled into sample.o, or sample.o was not linked into your dll.

I know I may be stating the obvious here, but it's worth checking.

Incidentally, I'm going to move some of these threads into another forum -- they should really be in the Plugin Development forum rather than the one about using plugins.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #8 on: March 06, 2009, 17:01:25 »


You're quite sure that the Aubio library files were included in the build and link, at this point?

The most obvious reason why you would have symbols such as _del_fvec undefined in the link would be simply that the file that defines them (e.g. sample.c, in this case) was not compiled and/or linked with the build.  That is, either sample.c was not compiled into sample.o, or sample.o was not linked into your dll.


That could be the problem here.

But I don't know how to do it. I'm sorry, I'm new in using Visual Studio.

Could you give me the steps on how to create it (e.g. sample.c compiled to sample.o)

Thanks. It could be a big help.

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #9 on: March 06, 2009, 17:05:56 »
Could you give me the steps on how to create it (e.g. sample.c compiled to sample.o)

Well, to be honest it should be enough to just add the files to your project.  If they are present in the project file listing, that should be enough...  If you re-build the project (i.e. build from clean), do the files you imported from aubio (e.g. sample.c) appear in the log of files being compiled?  I don't have Visual Studio to hand (running Linux at the moment) but I'm pretty sure it tells you what files it's compiling -- I can't remember whether it also tells you what files it is linking though.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #10 on: March 06, 2009, 17:13:42 »
If you re-build the project (i.e. build from clean), do the files you imported from aubio (e.g. sample.c) appear in the log of files being compiled? 

Actually no, only plugins.cpp and the .cpp that i did for my analyzer appears.


Hazel

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #11 on: March 07, 2009, 15:20:24 »
Hi,

I got to compile some of the codes of aubio and got this error from sample.cpp

----error C3861: 'malloc': identifier not found

How do I solved this.


Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #12 on: March 11, 2009, 14:23:42 »
You probably just need to put

Code: [Select]
#include <stdlib.h>

at the top of the source file.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #13 on: March 13, 2009, 12:01:53 »
Thanks, I got rid of the 'malloc' errors.

I have another problem with these errors.

--error C2057: expected constant expression
--error C2466: cannot allocate an array of constant size 0
--error C2133: 'buf' : unknown size

here's some of the codes.

//pitchschmitt.h

#ifndef _PITCHSCHMITT_H
#define _PITCHSCHMITT_H


#ifdef __cplusplus
extern "C" {
#endif

typedef struct _aubio_pitchschmitt_t aubio_pitchschmitt_t;

smpl_t aubio_pitchschmitt_detect (aubio_pitchschmitt_t *p, fvec_t * input);
aubio_pitchschmitt_t * new_aubio_pitchschmitt (uint_t size, uint_t samplerate);
void del_aubio_pitchschmitt (aubio_pitchschmitt_t *p);


#ifdef __cplusplus
}
#endif

#endif /* _PITCHSCHMITT_H */


//pitchschmitt.cpp
//part where i got those errors

#include <cstdlib>
#include "aubio_priv.h"
#include "sample.h"
#include "pitchschmitt.h"

smpl_t aubio_pitchschmitt_detect (aubio_pitchschmitt_t *p, fvec_t * input)
{
  signed short int buf[input->length];//errors occur here
  uint_t i;
  for (i=0; i<input->length; i++) {
    buf = input->data[0]*32768.;
  }
  return aubio_schmittS16LE(p, input->length, buf);
}

could you help me this compiler errors.

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: unresolved symbol errors while linking vamp plugin
« Reply #14 on: March 13, 2009, 15:57:20 »
Hi

I solved that errors which I stated above, now I got to compile all the codes but then I got error in linking..

These are the errors..

pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_pitchfcomb_detect referenced in function "float __cdecl aubio_pitchdetection_fcomb(struct _aubio_pitchdetection_t *,struct _fvec_t *)" (?aubio_pitchdetection_fcomb@@YAMPAU_aubio_pitchdetection_t@@PAU_fvec_t@@@Z)
1>pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_bintofreq referenced in function "float __cdecl aubio_pitchdetection_mcomb(struct _aubio_pitchdetection_t *,struct _fvec_t *)" (?aubio_pitchdetection_mcomb@@YAMPAU_aubio_pitchdetection_t@@PAU_fvec_t@@@Z)
1>pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_pitchmcomb_detect referenced in function "float __cdecl aubio_pitchdetection_mcomb(struct _aubio_pitchdetection_t *,struct _fvec_t *)" (?aubio_pitchdetection_mcomb@@YAMPAU_aubio_pitchdetection_t@@PAU_fvec_t@@@Z)
1>pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_pvoc_do referenced in function "float __cdecl aubio_pitchdetection_mcomb(struct _aubio_pitchdetection_t *,struct _fvec_t *)" (?aubio_pitchdetection_mcomb@@YAMPAU_aubio_pitchdetection_t@@PAU_fvec_t@@@Z)
1>pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_pitchyin_getpitchfast referenced in function "float __cdecl aubio_pitchdetection_yin(struct _aubio_pitchdetection_t *,struct _fvec_t *)" (?aubio_pitchdetection_yin@@YAMPAU_aubio_pitchdetection_t@@PAU_fvec_t@@@Z)
1>pitchdetection.obj : error LNK2019: unresolved external symbol _aubio_freqtomidi referenced in function _new_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _new_aubio_pitchfcomb referenced in function _new_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _new_aubio_pitchmcomb referenced in function _new_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _new_aubio_pvoc referenced in function _new_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _del_aubio_pitchfcomb referenced in function _del_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _del_aubio_pitchmcomb referenced in function _del_aubio_pitchdetection
1>pitchdetection.obj : error LNK2019: unresolved external symbol _del_aubio_pvoc referenced in function _del_aubio_pitchdetection
1>Debug\vamp-example-plugins.dll : fatal error LNK1120: 12 unresolved externals

I really cant move forward...pls help..