linker errors porting linux -> windows

Hi,

I want to port my application from linux to windows, and I've succeeded with most parts all the libraries are linked etc. etc.

However the compiler seems to think that I'm not building a console application.
I'm building it in debug mode using multibyte settings, and multi-threaded debug dlls, and the subsystem is set to console.

I do have a main function, and when I tried to create a console application with a main function I could, however I just can't understand why the compiler with these default settings can't link the main function.

main.cpp
1
2
3
4
5
6
7
8
9
10
11
#include "loop.h"

int main ( int argc, char* args[] )
{
    loop lp;

    lp.start();

    return 0;

}


well I think this is relevant and maybe the compiler settings I've already mentioned. Any ideas how can I solve this?

Best regards,
Yours3!f
What's the compilation/linker error message?
oh right i forgot it...


1>------ Build started: Project: proba2, Configuration: Debug Win32 ------
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Yours3lf\documents\visual studio 2010\Projects\proba2\Debug\proba2.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You're using a forbidden mix of multi-threaded debug libraries and non multi-threaded debug libraries.

Also, looks like your project settings are mixed up between console and windows-application. Dig though "project->properties->linker->system->subsystem" or whatever it's called now and make sure everything is set to console.

You might have found porting it easier if you'd not used Visual Studio, but that's a different conversation :)
Or create a new "project", and be sure to select Visual C++->General->Empty Project. Then add your files to that project. Empty project is what I use for all my console apps.
With Visual Studio, I usually find it easier to remake the project than to find my mistakes if I change too many options.
Last edited on
I tried that, it didn't work, now I'm recompiling the dependencies and I'll write when I'm done
@Moschops

that might be the problem, I'm recompiling them now

the system is console I double checked

yeah I know...
ok now I recompiled everything in mt debug dll mode, and it is still the same...
Use MT Debug, instead of MT Debug DLL. Also, if you built your dependencies as static libraries, make sure you disabled link time code generation
okay I recompiled everything in debug dll, now the warning is gone, and only this remained:

1>LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
Silly as it sounds, main.cpp (i.e. the cpp file containing your main function) is definitely part of the project, and is being compiled and linked? Your linker is complaining that it can't find it.
Are you by any chance using SDL? Try adding this in front of main():
1
2
3
#ifdef main
#error
#endif 
@Moschops yes main.cpp is part of the project. I tried to manually create a new main.cpp fill it and save it but the situation was the same.

@helios yes by any chance, and I added this snippet but the situation remained the same.
Topic archived. No new replies allowed.