Build Problem - Debug Vs Release

G

Guest

Hi there,

I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for
the debug version of the DLL (and this DLL works fine), however, I seem
unable to build a Release version of the DLL. If I do a 'Batch Build' and
select both Debug and Relase versions for building it will build the debug
version but throws up errors for the Release version. For example, the output
I get for a Batch Build is this -

--------------------Configuration: DartmNowWebSvcs - Win32
Release--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
DartmNowWebSvcs.cpp
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(109) : error C2491:
'ProcessData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(344) : error C2491:
'FreeOutData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(363) : error C2491:
'DisplayConfig' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(417) : error C2491:
'GetDLLVersion' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(450) : error C2491:
'GetDLLVersionH' : definition of dllimport function not allowed
DlgConfig.cpp
Generating Code...
Error executing cl.exe.

DartmNowWebSvcs.dll - 5 error(s), 0 warning(s)
--------------------Configuration: DartmNowWebSvcs - Win32
Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
DartmNowWebSvcs.cpp
DlgConfig.cpp
Generating Code...
Linking...
Creating library Debug/DartmNowWebSvcs.lib and object
Debug/DartmNowWebSvcs.exp

DartmNowWebSvcs.dll - 0 error(s), 0 warning(s)


I dont believe the code is wrong because I used the code from a template DLL
app and the template is written the same and gives no errors for a Release
build. Thus, it must be due to a link problem but after checking and checking
the Project Settings I can see no difference with the Settings? Unless I'm
missing a setting somwhere? Any advice offered much appreciated.

Thanks,
David
 
S

Severian [MVP]

Hi there,

I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for
the debug version of the DLL (and this DLL works fine), however, I seem
unable to build a Release version of the DLL. If I do a 'Batch Build' and
select both Debug and Relase versions for building it will build the debug
version but throws up errors for the Release version. For example, the output
I get for a Batch Build is this -

--------------------Configuration: DartmNowWebSvcs - Win32
Release--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
DartmNowWebSvcs.cpp
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(109) : error C2491:
'ProcessData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(344) : error C2491:
'FreeOutData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(363) : error C2491:
'DisplayConfig' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(417) : error C2491:
'GetDLLVersion' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cpp(450) : error C2491:
'GetDLLVersionH' : definition of dllimport function not allowed
DlgConfig.cpp
Generating Code...
Error executing cl.exe.

I dont believe the code is wrong because I used the code from a template DLL
app and the template is written the same and gives no errors for a Release
build. Thus, it must be due to a link problem but after checking and checking
the Project Settings I can see no difference with the Settings? Unless I'm
missing a setting somwhere? Any advice offered much appreciated.

Not the linker. Those errors are generated by the compiler (cl.exe).

My guess it that there is an #ifdef that defines some symbol to be
__declspec(dllimport) or __declspec(dllexport) based on some other
symbol. Compare the C++ compiler Defined Symbols settings for Release
vs. Debug.
 
G

Guest

Hi Severian,

Your guess is correct. In the code I have the following #ifdef block -

#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

But how do I access the - C++ compiler Defined Symbols settings for Release
vs. Debug ? Are they somehwere in the Project -> Settings ?

Thanks for your help!

David
 
G

Guest

Ok, I've chnaged this code from -

#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

to just this...

#define DLL_API __declspec(dllexport)


and it seems to be working ok now. Now I will try and work out 'why' (the
tricky bit ;-)

Cheers,
David
 
J

Jochen Kalmbach [MVP]

Hi David++!
Ok, I've chnaged this code from -

#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

to just this...

#define DLL_API __declspec(dllexport)


and it seems to be working ok now. Now I will try and work out 'why' (the
tricky bit ;-)

Yes, this works but now your program which uses your DLL (h-File) has
some trouble!

Please just define the "DLL_EXPORTS" in your preprocessor-settings!

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
G

Guest

I have just done this also! Phew, problem solved. Thanks for all your help!

Best,
David
 

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