VC++ link error

G

Guest

Hi All,

I have few link errors that i am not able to get rif off in a VC++ project
(plugin for filemaker) where i am trying to port the code written for a mac
to windows.

I am creating a object of a class and calling its member functions in
another file and during linking, i get the following error. Any pointer to
this issue is appreciated.

Prashanth

JCM_Functions.obj : error LNK2019: unresolved external symbol "public: short
__thiscall JCM_PDBfile::setFile(char const *,char *)"
(?setFile@JCM_PDBfile@@QAEFPBDPAD@Z) referenced in function "short __stdcall
JCM_SetFile(short,class fmx::ExprEnv const &,class fmx::DataVect const
&,class fmx::Data &)"
(?JCM_SetFile@@YGFFABVExprEnv@fmx@@ABVDataVect@2@AAVData@2@@Z)

// code in JCM_Functions.cpp
JCM_PDBfile* gDataFile = NULL;

// registered with FileMaker as external functions available via the plug-in.
FMX_PROC(fmx::errcode) ABC_SetFile(short index, const fmx::ExprEnv&
environment, const fmx::DataVect& dataVect, fmx::Data& results)
{
if(NULL != gDataFile)
{
gDataFile->close();
delete gDataFile;
gDataFile = NULL;
}

if(NULL == gDataFile)
{
gDataFile = new JCM_PDBfile;
if(NULL != gDataFile) // open file and read contents into obj's buffer
{
errorResult = gDataFile->setFile((const char*) charbuffer);
}
}

return(errorResult);
}
 
C

Carl Daniel [VC++ MVP]

prashanth said:
Hi All,

I have few link errors that i am not able to get rif off in a VC++ project
(plugin for filemaker) where i am trying to port the code written for a
mac
to windows.

I am creating a object of a class and calling its member functions in
another file and during linking, i get the following error. Any pointer to
this issue is appreciated.

You haven't shown any code for JCM_PDBfile::setFile(char const *,char *).
Presumably the code that you did include is from JCM_SetFile where the
reference occurs.

Usually the quickest way to resolve cases where a symbol is undefined that
you think should be defined is to use dumpbin /symbols on the .OBJ file
containing the reference and on the .OBJ file where you believe the symbol
(function in this case) should be defined.

Find the reference to setFile and the definition of setFile and see how
their full names differ. You might have a variety of inconsistencies
between how the function is defined and how the function is referenced that
would result in this kind of linker error:

- JCM_PDBfile declared as class in one place and as struct in another place
- const qualifiers not consistent
- "accidental" namespace issues (e.g. where the definition of the function
is inside a namespace, but the declaration that the calling site is using is
not in a namespace).
- different compiler options (e.g. caller expects __cdecl, but the function
was compiled as __stdcall).
- ...

Seeing the complete names from the point of definition and the point of
reference will usually tell you exactly what's wrong.

-cd

PS: dumpbin.exe is a command-line tool that's installed in your
<vs-install-dir>/VC7/BIN directory.
 
G

Guest

Thanks Carl,

It looks like JCM_PDBfile was compiled but (at the least the OBJ file was
created) but the dumpbin.exe showed that JCM_PDBfile.OBJ didn't have any
symbol information.

Why would that happen?

Prashanth
 
C

Carl Daniel [VC++ MVP]

prashanth said:
Thanks Carl,

It looks like JCM_PDBfile was compiled but (at the least the OBJ file was
created) but the dumpbin.exe showed that JCM_PDBfile.OBJ didn't have any
symbol information.

Why would that happen?

Typically, the cause for an .OBJ file to have no code in it is that the
source that was compiled contained no code.

For example, if you only cimpile the definition of a template class without
instantiating it, no code will be generated for that template. Now in your
case, the class doesn't appear to be a template, so it's something else.

It might be useful to compile the module in question with the /P
command-line option to produce a pre-processed output file (i.e. the source
file with all #includes and #defines expanded). That will let you see
exactly the text that the compiler itself saw. You might have a run-away
#ifdef or something like that that's causing the entire source file to be
skipped (although I think you'll get an error in that case).

-cd
 
G

Guest

Carl,

If i use the /P option, the linker gives me a WinExample fatal error
LNK1181: cannot open input file 'WinPluginDataDebug\JCM_Functions.obj' and
there was no .OBJ files in the output directory.

Also on testing, I see that the compiler completely ignores the text in
JCM_PDBfile.cpp after the #include "JCM_PDBfile.h" statement.

As a last resort, i have placed the project at the following address.
http://www.geocities.com/pkodela/FMPlugInSDK.zip

Can you please take a shot at it?
Thanks,
Prashanth
 
G

Guest

The problem was in the JCM_PDBfile.cpp file where some end of file characters
were found in the begining of the file and the compiler was ignoring all the
functions after the EOF character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top