467,074 Members | 841 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Build Problem - Debug Vs Release

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


Nov 17 '05 #1
  • viewed: 5020
Share:
5 Replies
On Thu, 21 Jul 2005 02:55:03 -0700, "David++"
<Da***@discussions.microsoft.com> wrote:
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.cp p(109) : error C2491:
'ProcessData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(344) : error C2491:
'FreeOutData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(363) : error C2491:
'DisplayConfig' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(417) : error C2491:
'GetDLLVersion' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(450) : error C2491:
'GetDLLVersionH' : definition of dllimport function not allowed
DlgConfig.cpp
Generating Code...
Error executing cl.exe.
<snip>
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.

--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.
Nov 17 '05 #2
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

"Severian [MVP]" wrote:
On Thu, 21 Jul 2005 02:55:03 -0700, "David++"
<Da***@discussions.microsoft.com> wrote:
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.cp p(109) : error C2491:
'ProcessData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(344) : error C2491:
'FreeOutData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(363) : error C2491:
'DisplayConfig' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(417) : error C2491:
'GetDLLVersion' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(450) : error C2491:
'GetDLLVersionH' : definition of dllimport function not allowed
DlgConfig.cpp
Generating Code...
Error executing cl.exe.


<snip>
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.

--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.

Nov 17 '05 #3
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

"David++" wrote:
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

"Severian [MVP]" wrote:
On Thu, 21 Jul 2005 02:55:03 -0700, "David++"
<Da***@discussions.microsoft.com> wrote:
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.cp p(109) : error C2491:
'ProcessData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(344) : error C2491:
'FreeOutData' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(363) : error C2491:
'DisplayConfig' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(417) : error C2491:
'GetDLLVersion' : definition of dllimport function not allowed
H:\WEBSERVICES\DartmNowWebSvcs\DartmNowWebSvcs.cp p(450) : error C2491:
'GetDLLVersionH' : definition of dllimport function not allowed
DlgConfig.cpp
Generating Code...
Error executing cl.exe.


<snip>
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.

--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.

Nov 17 '05 #4
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/
Nov 17 '05 #5
I have just done this also! Phew, problem solved. Thanks for all your help!

Best,
David

"Jochen Kalmbach [MVP]" wrote:

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/

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Steve Franks | last post: by
1 post views Thread by =?Utf-8?B?SlI=?= | last post: by
3 posts views Thread by Bob Johnson | last post: by
6 posts views Thread by =?Utf-8?B?SHVnaA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.