Pergunta

I first made a program in eclipse (mingw compiler). Now i am translating the code to Visual Studio 2008. It is one solution with multiple projects. 2 of the projects are for running a (console) program. The other 2 projects are helper classes for those. I have set the project dependencies so that the projects are compiled in the correct order. I now get an error message LNK2019 and LNK1120 because i have no main in the helper project. I have tried to compile the helper projects without linking but i cant find out how i should do that. I have tried adding the -c compiler option but unsuccessful. I have also tried to add a useless main to the helper project, but then compilation fails on compiling the real main with "function cannot be overloaded".

How can i fix this so i can have helper projects without a main?

Foi útil?

Solução

If you want to make a helper library you have to use the project type Class Library instead of Console Application

Outras dicas

You can compile your helpers as static libraries and link those to your main programs.

  1. Right-click on the project(s) in the Solution Explorer to compile them independently of the entire solution. You can also build them separately, which performs both compilation and linking.

  2. In Windows (I'm not sure about Linux), DLLs still require an entry point. The conventional name is DllMain. If you don't want an entry point, then you should create a static library instead of a DLL, which gets linked into your application at link time rather than dynamically loaded at run-time.

    You'll need to change your project's properties in order to tell it that you are now creating a static library, rather than a dynamic library. This will stop the linker from searching for a main function. You might find this walkthrough helpful.

    The "function cannot be overloaded" error is presumably because the dummy main function that you added has/had the wrong signature.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top