Discussion:
Newbie needing help with linker
(too old to reply)
Jim Flanagan
2013-11-02 01:58:16 UTC
Permalink
Hello -
I'm getting up to speed learning to use the open watcom tools. I am
attempting to link in some functions from a library that was created
with MS Visual C++ and am getting 'unresolved symbol' errors which are
due to name mangling (I'm assuming). My experience level isn't robust
enough at this point to resolve the problem. I recompiled my C
code using the -ecc switch and that seemed to fix the problem however it
appears that the library functions are not operating as expected. So,
I'm wondering if I am still doing something incorrect.

I would appreciate some tutoring as to the proper method to resolve my
issues. I've waded through the help files but am swimming in confusion.

Thanks for any help you may offer
Jim
Lynn McGuire
2013-11-02 16:22:09 UTC
Permalink
Post by Jim Flanagan
Hello -
I'm getting up to speed learning to use the open watcom tools. I am
attempting to link in some functions from a library that was created
with MS Visual C++ and am getting 'unresolved symbol' errors which are
due to name mangling (I'm assuming). My experience level isn't robust
enough at this point to resolve the problem. I recompiled my C
code using the -ecc switch and that seemed to fix the problem however it
appears that the library functions are not operating as expected. So,
I'm wondering if I am still doing something incorrect.
I would appreciate some tutoring as to the proper method to resolve my
issues. I've waded through the help files but am swimming in confusion.
Thanks for any help you may offer
Jim
You need to show us the errors and tell us more
about what you are doing. I do not know anything
about the -ecc switch. I do use third party DLLs.
I create my own link libraries for those though.

Thanks,
Lynn
Jiri Malak
2013-11-02 20:10:16 UTC
Permalink
Probably right solution is to use -3s compiler option.

Jiri
Post by Jim Flanagan
I'm getting up to speed learning to use the open watcom tools. I am
attempting to link in some functions from a library that was created
with MS Visual C++ and am getting 'unresolved symbol' errors which are
due to name mangling (I'm assuming). My experience level isn't robust
enough at this point to resolve the problem. I recompiled my C
code using the -ecc switch and that seemed to fix the problem however it
appears that the library functions are not operating as expected. So,
I'm wondering if I am still doing something incorrect.
I would appreciate some tutoring as to the proper method to resolve my
issues. I've waded through the help files but am swimming in confusion.
Thanks for any help you may offer
Jim
Jim Flanagan
2013-11-02 21:24:29 UTC
Permalink
Post by Jim Flanagan
Hello -
I'm getting up to speed learning to use the open watcom tools. I am
attempting to link in some functions from a library that was created
with MS Visual C++ and am getting 'unresolved symbol' errors which are
due to name mangling (I'm assuming). My experience level isn't robust
enough at this point to resolve the problem. I recompiled my C
code using the -ecc switch and that seemed to fix the problem however it
appears that the library functions are not operating as expected. So,
I'm wondering if I am still doing something incorrect.
I would appreciate some tutoring as to the proper method to resolve my
issues. I've waded through the help files but am swimming in confusion.
Thanks for any help you may offer
Jim
I am attempting to use a kernel driver called phymem.sys.

http://www.codeproject.com/Articles/35378/Access-Physical-Memory-Port-and-PCI-Configuration

The dll was compiled using Microsoft Visual C++ (I believe) and the
calling convention is unknown to me, but it appears to be cdecl. It
appears that Watcom uses a different, default calling convention. Using
the -ecc compile switch forces the compile to support cdecl. If I do
that then the linker is happy. Here is a simple test routine and the
errors reported.

======================================================================
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include "pmdll.h"

int main()
{
char* va = NULL;
BOOL b=LoadPhyMemDriver();

if (b==FALSE)
{
printf("load phymem.sys failed\n");
exit(-1);
}

va =(char*)MapPhyMem(0xF7020, 20);
printf("mapped virtual address = 0x%08x\n", va);
UnmapPhyMem(va, 20);

/*
DWORD d=ReadPortByte(0x379);
WritePortLong(0x378, 10);
d=ReadPortLong(0x378);
*/

printf("end");
getchar();

UnloadPhyMemDriver();
return 0;
}



cd C:\VGACode\phymem\PhyMem\test
wmake -f C:\VGACode\phymem\PhyMem\test\test.mk -h -e
C:\VGACode\phymem\PhyMem\test\test.exe
wlink name test d all sys nt op m libr pmdll.lib op v op maxe=25 op q op
symf @test.lk1
Error! E2028: __imp_LoadPhyMemDriver_ is an undefined reference
Error! E2028: __imp_MapPhyMem_ is an undefined reference
Error! E2028: __imp_UnmapPhyMem_ is an undefined reference
Error! E2028: __imp_UnloadPhyMemDriver_ is an undefined reference
file test.obj(C:\VGACode\phymem\PhyMem\test\test.c): undefined symbol
__imp_LoadPhyMemDriver_
file test.obj(C:\VGACode\phymem\PhyMem\test\test.c): undefined symbol
__imp_MapPhyMem_
file test.obj(C:\VGACode\phymem\PhyMem\test\test.c): undefined symbol
__imp_UnmapPhyMem_
file test.obj(C:\VGACode\phymem\PhyMem\test\test.c): undefined symbol
__imp_UnloadPhyMemDriver_
Error(E42): Last command making (C:\VGACode\phymem\PhyMem\test\test.exe)
returned a bad status
Error(E02): Make execution terminated
Execution complete
Lynn McGuire
2013-11-04 19:27:47 UTC
Permalink
Post by Jim Flanagan
I am attempting to use a kernel driver called phymem.sys.
http://www.codeproject.com/Articles/35378/Access-Physical-Memory-Port-and-PCI-Configuration
The dll was compiled using Microsoft Visual C++ (I believe) and the
calling convention is unknown to me, but it appears to be cdecl. It
appears that Watcom uses a different, default calling convention. Using
the -ecc compile switch forces the compile to support cdecl. If I do that then the linker is happy. Here is a simple test routine
and the
errors reported.
I've got some code similar to this at the bottom of:
http://www.winsim.com/diskid32/diskid32.html

Lynn

Loading...