icculus/steamshim

Errors linking against cpp

Closed this issue · 5 comments

Hi, thanks for this library, I'm hoping I can incorporate it into something we're working on.

I'm running into a variety of issues on Mac and Windows (mingw) platforms when linking against the Steamworks SDK, version 153a as of this writing. Linux had no problem that I can tell.

Mac:

clang++ -o steamshim -Wall -O0 -ggdb3 steamshim_parent.cpp -I sdk/public sdk/redistributable_bin/osx/libsteam_api.dylib
In file included from steamshim_parent.cpp:25:
In file included from sdk/public/steam/steam_api.h:21:
sdk/public/steam/steam_api_common.h:227:54: error: use of undeclared identifier 'nullptr'
        CCallbackManual() : CCallback< T, P, bGameServer >( nullptr, nullptr ) {}
                                                            ^
sdk/public/steam/steam_api_common.h:227:63: error: use of undeclared identifier 'nullptr'
        CCallbackManual() : CCallback< T, P, bGameServer >( nullptr, nullptr ) {}
                                                                     ^
In file included from steamshim_parent.cpp:25:
In file included from sdk/public/steam/steam_api.h:21:
In file included from sdk/public/steam/steam_api_common.h:233:
sdk/public/steam/steam_api_internal.h:87:11: error: use of undeclared identifier 'nullptr'
        m_pObj = nullptr;
                 ^
sdk/public/steam/steam_api_internal.h:88:11: error: use of undeclared identifier 'nullptr'
        m_Func = nullptr;
                 ^
sdk/public/steam/steam_api_internal.h:147:12: error: use of undeclared identifier 'nullptr'
        : m_pObj( nullptr ), m_Func( nullptr )
                  ^
sdk/public/steam/steam_api_internal.h:147:31: error: use of undeclared identifier 'nullptr'
        : m_pObj( nullptr ), m_Func( nullptr )
                                     ^
6 errors generated.

Windows (mingw):

x86_64-w64-mingw32-gcc -o steamshim -Wall -O0 -ggdb3 steamshim_parent.cpp -I sdk/public sdk/redistributable_bin/win64/steam_api64.lib 
In file included from /usr/share/mingw-w64/include/minwindef.h:163,
                 from /usr/share/mingw-w64/include/windef.h:8,
                 from /usr/share/mingw-w64/include/windows.h:69,
                 from steamshim_parent.cpp:8:
steamshim_parent.cpp: In function ‘bool launchChild(ProcessType*)’:
steamshim_parent.cpp:105:33: error: cannot convert ‘const char*’ to ‘LPCWSTR’ {aka ‘const wchar_t*’}
  105 |     return (CreateProcessW(TEXT(".\\") TEXT(GAME_LAUNCH_NAME) TEXT(".exe"),
      |                                 ^
      |                                 |
      |                                 const char*
In file included from /usr/share/mingw-w64/include/winbase.h:29,
                 from /usr/share/mingw-w64/include/windows.h:70,
                 from steamshim_parent.cpp:8:
/usr/share/mingw-w64/include/processthreadsapi.h:124:53: note:   initializing argument 1 of ‘WINBOOL CreateProcessW(LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, WINBOOL, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION)’
  124 |   WINBASEAPI WINBOOL WINAPI CreateProcessW (LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
      |                                             ~~~~~~~~^~~~~~~~~~~~~~~~~

Could this just be an example of an updated version of the SDK breaking some things? This all being said, I am not a C or CPP expert.

I managed to resolve the Mac problem by adding -Dnullptr=0 in the compilation options

Windows problem was related to CreateProcessW, I changed it to ChangeProcessA and it compiles, but static linking appears broken

For Windows, add -DUNICODE=1 to the command line and see if it fixes it...? It might be -D_UNICODE=1 instead.

I'm surprised clang++ didn't recognize nullptr. It might need -std=c++14 or something, I don't know. But yeah, 0 is good enough, too.

-DUNICODE=1 compiled fine, thanks!
I'm running the steamshim.exe in the same directory as the application it's trying to launch (q2pro.exe) I get an Application Error

The application was unable to start correctly (0xc0000005).

Something about access violations regarding the value being a const string?

Mac and Linux builds seem to work fine, I'm figuring out the best way to get to launch via a bundled app for Mac, but Linux only needed a little bit of massaging with -rpath to get it to load the lib from the same directory

Closing this issue since my main issue lies with the passing of arguments to CreateProcessW rather than compiling