#1039 --add-stdcall-alias and -shared options

OTHER
closed
nobody
gcc (462)
works-for-me
User_Error
2013-01-31
2007-05-20
Jim Pattee
No

* OS version ( Windows XP )
* gcc version ( 3.4.2 )
* ld version ( 2.15.94 )
* mingw-runtime version ( 3.9 )
* w32api version ( 3.6 )

I have a program that loads a dll explicitly using LoadLibrary() and GetProcAddress(). GetProcAddress uses the UNDECORATED function name in the dll call.

When the dll is compiled using dllwrap.exe and the option --add-stdcall-alias, the dll is called without a problem.

When the dll is compiled using g++ with the -shared option and --add-stdcall-alias, the GetProcAddress fails with "The specified procedure could not be found." When I add the @16 suffix to the function name it is called correctly. It seems like the --add-stdcall-alias doesn't have an effect when g++ is used with the -shared option.

Following is a copy of the command line used to call the linker. The file libAStyle.a is not used in linking the calling program.

-----------------------------------------------

g++.exe -shared ../objd/ASBeautifier.o ../objd/ASEnhancer.o ../objd/ASFormatter.o ../objd/ASResource.o ../objd/astyle_main.o -L"C:/_jpFiles/Programs/Dev-Cpp/Lib" --add-stdcall-alias --no-export-all-symbols -s -Wl -Wl,--out-implib,../bin/libAStyle.a -o ../bin/AStyle.dll

Creating library file: ../bin/libAStyle.a

Execution terminated
Compilation successful

Discussion

  • Danny Smith

    Danny Smith - 2007-05-20

    Logged In: YES
    user_id=11494
    Originator: NO

    --add-stdcall-alias is a linker, not a compiler, option.
    You should have gotten a warng like:
    unrecognized command line option "-fadd-stdcall-alias"

    Try using -Wl,--add-stdcall-alias

    Danny

     
  • Jim Pattee

    Jim Pattee - 2007-05-21

    Logged In: YES
    user_id=826897
    Originator: YES

    Thanks, that fixed the problem.

    But...
    there was no warning or error when it was sent thru wrong. There was just a run-time error when the function couldn't be located.

     
  • Jim Pattee

    Jim Pattee - 2007-05-21

    Logged In: YES
    user_id=826897
    Originator: YES

    I did some more testing and found the following:

    --add-stdcall-alias works only if there is no space after the comma
    -Wl,--add-stdcall-alias

    if there is a space
    -Wl, --add-stdcall-alias
    or if it is placed anywhere else in the area it doesn't seem to work.

    Again, it compiles OK, but it cannot locate the function at run-time.

     
  • Danny Smith

    Danny Smith - 2008-06-15

    Logged In: YES
    user_id=11494
    Originator: NO

    Worhs as per documentation, so not a bug.

     
  • Danny Smith

    Danny Smith - 2008-06-15
    • status: open --> closed-works-for-me
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-31
    • labels: --> gcc
    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> User_Error
    • milestone: --> OTHER
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks