I have the following two files:
- foo.h
- bar.cpp
In foo.h I decleare a variable extern.
Now, I would like to use the same variable in bar.cpp (after including foo.h).
Under VS2008 and VS2010 I get unresolved external symbol errors, while under Ubuntu with gcc the compilation is successfull.
(Namely, I’m trying to compile the following source code:http://www.fromdual.com/using-mysql-user-defined-functions-udf; foo.h refers to srv0srv.h and bar.cpp refers to the source code. All includes are in place, compilation is a success, linking falls)
What might the problem be?
The problem was, that the afformentioned symbol has to be exported (via dllspec) from the dll, to be visible from outside. Only the extern keyword did not allowed it to be seen from outside.