Jump to content


p4api C++, Visual Studio 2015

vs2015 visual studio 2015 c++

  • Please log in to reply
3 replies to this topic

#1 Sagaceil

Sagaceil

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 17 December 2015 - 12:04 PM

Hello !

I'm tried to adopt p4api C++ ( from http://cdist2.perfor...15.2/bin.ntx86/), but newest version of binaries seems to be using _MSC_VER 1800. Its in conflict with VS2015 that uses 1900. What's more is that there are linking errors (since VS2015 had changed a bit std libs) and I hit the wall with a bunch of those little guys:


Error LNK2001 unresolved external symbol ___iob_func libsupp.lib(fileiont.obj)

Error LNK2001 unresolved external symbol "int __cdecl _wopen(wchar_t const *,int,int)" libsupp.lib(fileiont.obj) 1

It's impossible to me to rollback to VS2013 now. Question: Is there some plans to release vs2015 binaries somehow in near future ?

Thanks for any reply :)

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 17 December 2015 - 09:15 PM

Hi,

Sorry you are having trouble with linking errors.

It sounds like the issue may be that your MSVC compiler is not supported with the Perforce C++ API, thus Visual Studio is not linking libraries created from earlier versions perhaps. We do not have enough information to know for sure. To better trouble-shoot:

a] Which versions of the following are you using?

- Visual Studio
-  P4VS
-  C++ API

b] Were you using an earlier version of Visual Studio before?

If need be, you can get an earlier version of P4VS (or any other product) from our ftp site. For example:

http://ftp.perforce.....ntx86/p4vs.exe

Check the release notes compatibility details with the versions that you are using for Visual Studio, P4VS and the C++ API:

  https://www.perforce.../p4apinotes.txt

  https://www.perforce...r/p4vsnotes.txt

I'm not sure if this is related to your issue, but there is an existing request for a new build of P4API using VS 2015 due to library compatibility issues. Some user hacks to make an old VS 2012 version work, for example, were:

- To get the VS 2012 libs to work in VS 2015 replace the string "_MSC_VER=1700" to "_MSC_VER=1900" in librpc.lib.

- Fixed a small warning in filesys.h (line 325): warning C4458: declaration of 'perms' hides class member. But after that is seems to be working.

#3 Sagaceil

Sagaceil

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 21 December 2015 - 11:35 AM

Hello,

According to your questions: I'm using Visual Studio 2015, P4VS newest from download section (but i believe that its not needed to use p4api), newest C++ api avaible for ntx architecture (I mentioned link in my first post).

Previous version of Visual Studio 2013 works fine with that lib (since its explicitly compiled under that environment).

And those hacks that you described only hides one of linking problem. The only solution that would be clean (more and more people will face with VisualStudio2015 issue as its getting adapted very fast) is just to release native libs that were compiled using VusialStudio2015 :)

#4 Sagaceil

Sagaceil

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 21 December 2015 - 07:09 PM

1800 -> 1900 trick by editing .lib file using hexedit shouted down linker.
The __iob_func can be hacked by something like:

static FILE _iob[] ={ *stdin, *stdout, *stderr };

extern "C" FILE * __cdecl __iob_func( void )
{
return _iob;
}

But remaning ones cannot be bypassed easly.

libsupp.lib(fileiont.obj) : error LNK2001: unresolved external symbol "int __cdecl _wopen(wchar_t const *,int,int)" (?_wopen@@YAHPB_WHH@Z)
libsupp.lib(debug.obj) : error LNK2001: unresolved external symbol _vprintf

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

There is one more thing also. When using p4api with Windows headers 'SetPort' method in 'class ClientApi' :

void SetPort( const StrPtr *c );

Is in conflict with define used by winspool.h :


#ifdef UNICODE
#define SetPort SetPortW
#else
#define SetPort SetPortA
#endif // !UNICODE
So in the end SetPort is overriden by this macro and ABi is broken since in lib there is 'SetPort' and linker search for 'SetPortA' / 'SetPortW'. This can be easly fixed by undefing SetPort before clientapi.h .





Also tagged with one or more of these keywords: vs2015, visual studio 2015, c++

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users