Jump to content
  • Advertisement
Sign in to follow this  
CTar

Export creates error

This topic is 2765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple header file:
#ifndef M1ABASE__LOGGING__ILOG__HEADER
#define M1ABASE__LOGGING__ILOG__HEADER

namespace Miraoh1A
{
	namespace Logging
	{
		class iLog
		{};
	}
}

#endif

The problem is that the moment I try to export it I get the following errors (from the linker):
M1ABase error LNK2005: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj
M1ABase error LNK2005: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj
M1ABase error LNK2005: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj
M1ABase error LNK2005: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj
M1ABase error LNK2005: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj
M1ABase warning LNK4006: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj; second definition ignored
M1ABase warning LNK4006: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj; second definition ignored
M1ABase warning LNK4006: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj; second definition ignored
M1ABase warning LNK4006: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj; second definition ignored
M1ABase warning LNK4006: ___@@_PchSym_@00@UnrizlsBzUtziyztvUnBzyzhvUwvyftLnfogrgsivzwvwLfmrxlwvUxrmurovBOlyq@ already defined in Convert.obj; second definition ignored
M1ABase fatal error LNK1169: one or more multiply defined symbols found

The code which exports look like this:
#ifndef M1ABASE__LOGGING__ILOG__HEADER
#define M1ABASE__LOGGING__ILOG__HEADER

namespace Miraoh1A
{
	namespace Logging
	{
// I also tried with the approach where you make
// a define which are either __declspec(dllexport) or
// __declspec(dllimport).
		class __declspec(dllexport) iLog
		{};
	}
}

#endif

Does anyone have an idea of what is wrong? The errors aren't exactly descriptive. I use Visual Studio 2003 .Net. If I remove the convert.cpp (error occured in convert.obj) file from the project the linker gives me the same errors, just with InFile.obj instead of convert.obj.

Share this post


Link to post
Share on other sites
Advertisement
might be some sort of project setting or the way you have linked
ur libraries. post a pic of your Properties->General and Properties->Linker->General section
of the project properties dialog.

MSDN also says that LNK4006 can happen when you merge import
libraries and LNK2005 can happen when you mix single/multi-threaded.
libraries. so many things can cause these errors. in fact, if you
can, post a sample solution; that way we can look at the settings
and switches without you posting a bunch of pics. otherwise i suggest
looking up those LNKs in MSDN and going through their possible causes
and eliminate the ones it can or can't be.

[Edited by - yadango on September 23, 2005 11:51:51 PM]

Share this post


Link to post
Share on other sites
I have looked the errors up on MSDN and cant find anything useful, I have also tried to let Visual Studio create a new DLL project and compare the settings and they are almost equal (warning level, treat warning as error, addition include directory etc. are different).

Anyway I have two projects, M1ABase and M1AKernel, their settings are (M1ABase are the one generating linker errors):

M1A_HOME is an envirorment variable which points to the engine directory(D:\Miraoh1A\)

M1ABase

General:
Output Directory: $(M1A_HOME)\Bin\
Intermediate Directory: $(M1A_HOME)\Garbage\$(ProjectName)\$(ConfigurationName)\
Configuration type: Dynamic Library (.dll)
Use of MFC: Use Standard Windows Libraries
Use of ATL: Not using ATL
Character Set: Use Unicode Character Set
Use Managed Extensions: No
Whole Program Optimization: No

C++->General:
Additional Include Directories: $(M1A_HOME)\Include\
Debug Information Format: Program Database for Edit & Continue (/ZI)
Suppress Startup Banner: Yes (/nologo)
Warning Level: Level 4 (/W4)
Detect 64-bit Portability Issues: Yes (/Wp64)
Treat Warnings As Errors: Yes (/WX)

C++->Preprocessor:
Preprocessor Definitions: WIN32;_DEBUG;_WINDOWS;_USRDLL;M1ABASE_EXPORTS
Ignore Standard Include Path: No
Generate Preprocessed File: No
Keep Comments: No

C++->Code Generation:
Enable String Pooling: No
Enable Minimal Rebuild: Yes (/Gm)
Enable C++ Exceptions: Yes (/EHsc)
Smaller Type Checks: Yes (/RTCc)
Basic Runtime Checks: Both (/RTC1, equiv. to /RTCsu)
Runtime Library: Multi-threaded Debug (/MTd)
Struct Member Alignment: Default
Buffer Security Checks: Yes (/GS)
Enable Function Level Linking: No
Enable Enchanced Instruction Set: Not set

C++->Language:
Disable Language Extensions: No
Default Char Unsigned: No
Treat wchar_t As Build-in Type: Yes (/Zc:wchar_t)
Force Conformance In For Loop Scope: No
Enable Run-Time Type Info: No

C++->Precompiled Headers:
Create/Use Precompiled header: Create Precompiled Header (/Yc)
Create/Use PCH Through File: M1ABase\\stdafx.hpp
Precompiled Header File: $(IntDir)/$(TargetName).pch

C++->Advanced:
Calling Convention: __cdecl (/Gd)
Compile As: Compile as C++ Code (/TP)
Show Includes: No
Undefine All Preprocessor Definitions: No

Linker->General:
Output File: $(OutDir)$(ProjectName)MTUd.dll
Enable Incremental Linking: Yes (/INCREMENTAL)
Additional Library Directories: $(M1A_HOME)\Lib\

Linker->Input:
Additional Dependices: (none)
Ignore All Default Libraries: No

Linker->Debugging:
Generate Debug Info: Yes (/DEBUG)
Generate Program Database File: $(IntDir)/$(ProjectName).pdb
Generate Map File: No

Linker->System:
SubSystem: Windows (/SUBSYSTEM:WINDOWS)

Linker->Advanced:
Resource Only DLL: No
Fixed Base Address: Default
Import Library: $(M1A_HOME)\Lib\$(ProjectName)MTUd.lib
Target Machine: MachineX86 (/MACHINE:X86)




M1AKernel:

General:
Output Directory: $(M1A_HOME)\Bin\
Intermediate Directory: $(M1A_HOME)\Garbage\$(ProjectName)\$(ConfigurationName)\
Configuration type: Dynamic Library (.dll)
Use of MFC: Use Standard Windows Libraries
Use of ATL: Not using ATL
Character Set: Use Unicode Character Set
Use Managed Extensions: No
Whole Program Optimization: No

C++->General:
Additional Include Directories: $(M1A_HOME)\Include\
Debug Information Format: Program Database for Edit & Continue (/ZI)
Suppress Startup Banner: Yes (/nologo)
Warning Level: Level 4 (/W4)
Detect 64-bit Portability Issues: Yes (/Wp64)
Treat Warnings As Errors: Yes (/WX)

C++->Preprocessor:
Preprocessor Definitions: WIN32;_DEBUG;_WINDOWS;_USRDLL;M1AKERNEL_EXPORTS
Ignore Standard Include Path: No
Generate Preprocessed File: No
Keep Comments: No

C++->Code Generation:
Enable String Pooling: No
Enable Minimal Rebuild: Yes (/Gm)
Enable C++ Exceptions: Yes (/EHsc)
Smaller Type Checks: Yes (/RTCc)
Basic Runtime Checks: Both (/RTC1, equiv. to /RTCsu)
Runtime Library: Multi-threaded Debug (/MTd)
Struct Member Alignment: Default
Buffer Security Checks: Yes (/GS)
Enable Function Level Linking: No
Enable Enchanced Instruction Set: Not set

C++->Language:
Disable Language Extensions: No
Default Char Unsigned: No
Treat wchar_t As Build-in Type: Yes (/Zc:wchar_t)
Force Conformance In For Loop Scope: No
Enable Run-Time Type Info: No

C++->Precompiled Headers:
Create/Use Precompiled header: Create Precompiled Header (/Yc)
Create/Use PCH Through File: M1AKernel\\stdafx.hpp
Precompiled Header File: $(IntDir)/$(TargetName).pch

C++->Advanced:
Calling Convention: __cdecl (/Gd)
Compile As: Compile as C++ Code (/TP)
Show Includes: No
Undefine All Preprocessor Definitions: No

Linker->General:
Output File: $(OutDir)$(ProjectName)MTUd.dll
Enable Incremental Linking: Yes (/INCREMENTAL)
Additional Library Directories: $(M1A_HOME)\Lib
Linker->Input:
Additional Dependices: (none)
Ignore All Default Libraries: No

Linker->Debugging:
Generate Debug Info: Yes (/DEBUG)
Generate Program Database File: $(IntDir)/$(ProjectName).pdb
Generate Map File: No

Linker->System:
SubSystem: Windows (/SUBSYSTEM:WINDOWS)

Linker->Advanced:
Resource Only DLL: No
Fixed Base Address: Default
Import Library: $(M1A_HOME)\Lib\$(ProjectName)MTUd.lib
Target Machine: MachineX86 (/MACHINE:X86)




[Edited by - CTar on September 24, 2005 5:43:18 AM]

Share this post


Link to post
Share on other sites
This header file containing the empty declaration of iLog were included in the precompiled header, which looks like this:


#ifndef M1A_BASE__STDAFX__HEADER
#define M1A_BASE__STDAFX__HEADER

#include <cassert>
#include <vector>

#include "M1ABase\\Config\\Config.hpp"
#include "M1ABase\\Types.hpp"

#include "M1ABase\\Logging\\iLog.hpp"

#endif



One thing I have discovered is that if I comment out:
#include "M1ABase\\Logging\\iLog.hpp"
And replaces every occurence of:
#include "M1ABase\\stdafx.hpp"
With:
#include "M1ABase\\stdafx.hpp"
#include "M1ABase\\iLog.hpp"

This should give the same code, but I get no errors when the include is in the .cpp files instead of the precompiled header.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
oh ok, i see now. i replicated all your errors.
those linker errors are because after you create
your precomp header (pch) file, you didn't change
the compiler setting from Create Precompiled Header
to Use Precompiled Header.

1.) So delete your binaries.
2.) Go to the project's properties and change the
C++->Precompiled Headers to Use Precompiled Header.
3.) Now right-click on stdafx.cpp, or the cpp module
that you are going to base your PCH on, and set
C++->Precompiled Headers to Create Precompiled Header.
4.) Compile stdafx.cpp.
5.) Build all.
5.) Since you are using __dllexport in your precomp
header, you cannot switch stdafx.cpp's C++->Precompiled Headers
property to Use Precompiled Header, so don't worry about
changing this setting. If you do, you'll get linker error
1825 I think, which basically says "you shouldn't put
exportable components in precompiled header files."

yadango

Share this post


Link to post
Share on other sites
Thanks alot yadango it works know, unfortunatly I cant rate you up (anonymous).

EDIT: I guess you are the yadango posting the first reply, so will rate him/her (probably him) up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!