VC++ 2005 Linker instead of PellesC

Windows specific forum
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

VC++ 2005 Linker instead of PellesC

Post by Polo »

Hi,

I've talked a lot about the troubles I had using .lib files compiled with VC++ 2005 (or higher) in Purebasic, especially when there's C++ code involved.

It'd be handy if you switched the Purebasic linker to the VC's one, it would require us all to install VC2005 (as you probably cannot distribute it directly in Purebasic), but the result would be much better !

cheers
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

So you probably understand why we don't want to have a 500 MB dependency just to compile an "hello world" in purebasic. We have no problem with pelles C one here, as long you compile the code correctly (as we talked in your thread). BTW, from what i understand, the polink.exe commanline options maps the VC one, did you tried to replace it ?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Fred wrote:So you probably understand why we don't want to have a 500 MB dependency just to compile an "hello world" in purebasic. We have no problem with pelles C one here, as long you compile the code correctly (as we talked in your thread). BTW, from what i understand, the polink.exe commanline options maps the VC one, did you tried to replace it ?
No, but I'm going to try :) !
Thanks for the answer, I'll tell you what the results are!
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Ok, tried, and I got unresolved externals all the way (I copied link.exe and renamed it to polink.exe, plus I copied mspdb80/dll and cvtres.exe)

For a blank source with only "MessageRequester("","")" in it, I get 9 unresolved, which probably means it doesn't link the system lib files ?

(one is __imp__MessageBoxA)
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Polo wrote:Ok, tried, and I got unresolved externals all the way (I copied link.exe and renamed it to polink.exe, plus I copied mspdb80/dll and cvtres.exe)

For a blank source with only "MessageRequester("","")" in it, I get 9 unresolved, which probably means it doesn't link the system lib files ?

(one is __imp__MessageBoxA)
I've tried this before and got it work with PB4.10 but never bothered doing anything else with it. IIRC the library paths point to the PureLibraries\Windows path, which MSVC doesn't really like. So I was going to write a small stub program which replaced polink.exe, removed all the PellesC stuff and then called the link.exe.

You should also look at the "MSVC2005 command prompt" shortcut for the initialisation required to set the paths for the MSVC tools rather than simply copying the files.

I only got as far as getting the compiled source files from PureBasic and the libraries, but then had to call link manually.

Below is some source which might help you see what's going on when polink is called by PureBasic.

Code: Select all

#include "stdafx.h"
#include <cstdio>
#include <cstdlib>

#include <string>
#include <sstream>
#include <fstream>
#include <vector>

#include <windows.h>

#include "Path.h"

using namespace std;
using namespace nsPath;

void CopyCompilerFiles(void)
{
    CPath   path(nsPath::GetCurrentDirectory());
    
}

int main(int argc, char*argv[])
{
    stringstream    str;
    
    CopyCompilerFiles();
    
    str << "polink_orig.exe ";
    for(int i = 1; i < argc; ++i)
    {
        str << """ << argv[i] << "" ";
    }

    ofstream log("c:\\polink.log");
    log << str.str().c_str();
    log.close();

    Sleep(10000);
    
    return(system(str.str().c_str()));
}
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Fred wrote:We have no problem with pelles C one here, as long you compile the code correctly
The trouble is, when I follow your instruction, I still get some errors, here they are:
3 unresolved external symbols:

'__security_cookie'
'@__security_check_cookie'
'_imp___iob_func
I don't mind using the PellesC linker but I'd like to have that C++ library running with Purebasic ;)
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

__security_cookie and such can be solved by desactivate the appropriate VC code flag (see C++ -> Code Generation -> Buffer Security Check -> No) or link with bufferoverflowu.lib. For the io problem, that's because we don't use the VC8 runtime, but the standard MSVCRT to be compatiable with older OS without any dependencies. To solve it, you can define this alias as main define: /D__iob_func=__p__iob
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Fred wrote:__security_cookie and such can be solved by desactivate the appropriate VC code flag (see C++ -> Code Generation -> Buffer Security Check -> No) or link with bufferoverflowu.lib. For the io problem, that's because we don't use the VC8 runtime, but the standard MSVCRT to be compatiable with older OS without any dependencies. To solve it, you can define this alias as main define: /D__iob_func=__p__iob
:shock:

You solved all my problems with 3 lines :!:
Thanks a lot Fred, I don't need to use VC linker now !
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Good. BTW, using the VC linker wouldn't have solved these problems, as they were not linker related.
Post Reply