visual studio 2008 - ATL project created using wizard does not compile due to unresolved symbols -
I'm working to get basic ATL projects to be compiled in Visual Studio 2008 and I'm running in errors I am Eventually I was stuck with the following build errors:
1> Linking ... 1 & gt; Library debug \ SomeProject.lib and object debug \ SomeProject.exp 1 & gt; Dllmain.obj: Error LNK2001: Unsolved External Symbol _LIBID_SomeProjectLib 1 & gt; SomeObject.obj: Error LNK2001: Unsolved External Symbol _LIBID_SomeProjectLib 1 & gt; SomeObject.obj: Error LNK2001: Unsolved External Symbol _IID_ISomeObject 1 & gt; Debug \ SomeProject.dll: Fatal error LNK1120: 2 unsolved embedded
What am I seeing or doing wrong? These steps are given to reproduce.
- Create a new
ATL project
namedSomeProject
. Accept all the mistakes. - Right-click the project in the Solution Explorer and click
Add & gt; Class
. - Enter
ATL Simple Object
and enterSomeObject
as its code Accept all other defaults.
The project fixes at this point. However, I want to split my IDL into multiple files for better organization (my IDL will be thousands of lines long).
- Right-click on the project and select
Add & gt; New item
. Choose -
middle file
and enterISomeObject
as its code. -
Open some projects .idl
andISomeObject
cut the Interface Announcement. Change it toimport "ISomeObject.idl"
. - Paste the Interface Announcement in
ISomeObject.idl
.
To satisfy the Microsoft's IDL compiler, we need to change some options:
- Right-click on the project and open its properties < Code> MIDL> Go to the Output section and enter the following value:
- Header file:
$ (input name). H
- ID file:
$ (InputName) _i.cpp
- Proxy file:
$ (input name) _p.cpp < / Code>
- Generate Type Library:
No
- Go to
C / C ++> Precompiled Headers
Do not use precompiled header from section and setcreate / use precompiled header
. Later errors are if precomputed headers are used. - Select the
SomeProject.idl
file so that its properties can be displayed.MIDL & gt; Go to Output
section and setto Library
toYes
. - Remove
someProject_i.h
andSomeProject_i.c
tothe generated files
. - Add existing code to
generated files
filter You may have to try to compile the project first-
SomeProject.h < / Code>
-
SomeProject_i.cpp
-
ISomeObject.h
-
ISomeObject_i.cpp But this is not you should get the
LNK1120
errors listed at the top of this questionAny thoughts? Am I looking something simple?
-
- Header file:
Not sure what you are doing, or why you are doing this, but somewhere You have lost the blah_i.c source code file which generates midl.exe, which contains GUIDs of interfaces, cockles and type libraries about which the linker is complaining about. If you can not find it back, then search for MIDL_DEFINE_GUID in * .c files.
EDIT: I see the problem now, you named blah_i.c as blah_i.cpp. This is incorrect, there are C announcements in the file. Compiler connects identifiers differently when it is compiled as a C ++ code, rename it back. C. Or use the / TC compilation option.
Comments
Post a Comment