While trying to build a project in RadAsm, i've run into a problem during linking and I am getting :

FileDlgs.lib(FileDlgs.obj) : error LNK2005: _pszFilter already defined in oatest.obj
oatest.exe : fatal error LNK1169: one or more multiply defined symbols found

But,only when I use "LoadObjects" to add the FileDlgs object to the main app.
If I use "MakeObjects" to add the object to the project, the project builds just fine, and things work as they should.
Here is the problem Code:

%include @Environ(OA32_PATH)\\Code\\Macros\\Model.inc      ;Include & initialize standard modules
SysSetup OOP_WINDOWS, DEBUG(WND, RESGUARD)                ;Loads OOP files and OS related objects

include oatest Globals.inc                                  ;Includes application globals
IncludeBoth HtmlHelp
IncludeBoth comdlg32

; here is the problem line
LoadObjects FileDlgsPrimer,FileDlgs  ; if I change LoadObjects to MakeObjects
                                                ; this app builds correctly
LoadObjects Dialog, DialogModal, DialogAbout                ;Loads or builds the following objects
LoadObjects SdiApp

include oatest.inc                                          ;Includes oatest object

start:                                                      ;Program entry point
    SysInit                                                ;Runtime initialization of OOP model

    ResGuard_Start                                          ;Activates ResGuard
    OCall @oatest::oatest.Init                        ;Initializes the object data
    OCall @oatest::oatest.Run                        ;Executes the application
    OCall @oatest::oatest.Done                        ;Finalizes it
    ResGuard_Show                                          ;Shows ResGuard results

    SysDone                                                ;Runtime finalization of the OOP model
    invoke ExitProcess, 0                                  ;Exits program returning 0 to the OS
end start                                                  ;Code end and defines prg entry point

BTW, I can compile the object(FileDlgs), and its' ancestor just fine using the compile object option in RadAsm.
Thanks in advance,
Posted on 2007-07-22 22:34:35 by rags
Hi rags
I guess that the problem is a wrong symbol redefinition or duplication in one of the objects FileDlgsPrimer,FileDlgs. If you can attach or send them to me, I can try to find out where the problem is.
The reason why LoadObjects works fine is because not all of the object symbols are exposed when the lib version is linked. On the other side, MakeObjects includes the full source code, so the compiler can all of them.


Posted on 2007-07-23 01:08:30 by Biterider
Thanks Biterider, I emailed them to you.
Posted on 2007-07-23 09:57:58 by rags
Hi Rags
The solution for your problem is moving the declaration of pszFilter (should be szFilter) below the “if IMPLEMENT” line.
The reason is because the file you use to write an object is divided into 2 sections. The first one is the header, and the second is the real implementation. Both are separated by the “if IMPLEMENT” line.
Now, when you create the lib file, the code of the implementation section and the symbols declared in the object header section are included in the final lib file.
Using LoadObject, only the header section is exposed to the compiler so the application can know about the structure of the object together with the library you build before. As you can see now, the symbol you had declared in the header section is now present twice, rising the error you have seen.

I hope I have clarified this issue.  ;)


Posted on 2007-07-23 10:31:40 by Biterider

I hope I have clarified this issue.  ;)

Thank you for the clarification, I understand now. : :)
Posted on 2007-07-23 10:48:53 by rags