How to use a project with no entry point in Visual Studio - c++

I'm porting a project over to Visual Studio and running into this problem. I have a project that I want to build and use as part of my solution, but it won't build itself.
When I build the solution, that project gives the error "No entry point".
The other main project that will rely on this library project then gives linker errors, since this won't build. What is the correct approach for this?
For reference, the code I'm trying to build is from here, and the library is imageLib.zip from there.

Go to the project properties page, and set "Configuration type" to "Static library" or "Dynamic library", rather than "Application". You might also need the /NOENTRY flag.

In Project Properties, Configuration -> General -> Configuration Type should be either Static library (.lib) or Dynamic Library (.dll).

probably, project that you are trying to port is static library, or DLL, both don't have a "classic" main function. Try to change Configuration type, or define entry point.

Related

Is it possible to create a static library C++ with Visual Studio 2013 Community Edition?

I had a C/C++ Visual Studio 2013 Community Edition project that was defined to generate a DLL, and I'm having a lot of misery with "undefined symbols" which I wanted to use in another project, so I decided to see what it would give if I changed the project settings so that it would generate a static library instead.
So in the Properties window of the project I went to
Configuration Properties > General > Project Defaults > Configuration Type
and set the Configuration Type to Static Library
The target extension is .lib.
When I do a rebuild I still get a fresh dll file in my Release folder, as well as a lib, and the DLL file is much bigger than the lib file. This makes the lib file look like an "export lib" file and it looks like nothing has changed.
This still happens if I stop and restart Visual Studio.
Am I missing something or does this look like a bug to you?
In Configuration Properties - C/C++ - Runtime Library change setting to Multi-threaded (/MT) for Release configuration and to Multi-threaded Debug (/MTd) for Debug configuration.
Also, check Configuration Properties - General - General - Target extension is set to .lib.
Check settings for all configurations (Release and Debug if you use them).
Why have you changed your project type? If you need DLL, build DLL. Post exact errors received during DLL compilation. Perhaps you missed some dllexport/dllimport declspecs.
Regarding .lib: are you sure, that DLL is generated during build? Perhaps it is the output from previous (DLL) configuration? Have you tried to compile test app using this .lib? Perhaps it is valid and compiled properly?
Another matter: have you removed all dclspecs from function signatures after project type change? When building static library, none of them are applicable.

How can I build a library as a .dll and not a .lib

I got this c++ physics library liquidfun
Theyve included a visual studio solution for building the library for windows.
When I build it it gives me a .lib but I want a .dll so I can use it with Unity3d.
Is there a way of changing the build setting of a project in visual studio to get a .dll and not a .lib?
EDIT:
The very simple fix of just changing it in the project properties actually worked for me! This is probably due to the library itself being really well written.
It didnt work when I tried the same thing before I posted this question but that was caused by a problem with my c++ code
Yes, you can generate a dll instead of a lib. To do this in VS right click on your project -> properties -> Configuration Properties -> General. In the "Project default" section go to "Configuration Type" and change it to "dynamic library .dll". Then do not forget to generate it ;)
PS : DLL, not >LIB of course ;)
The easiest way is to build your VS solution from cmake.
I don't have the parameter at hand right now but cmake can list the parameters for you.
I think it was -DBUILD_SHARED_LIBS

Error LNK1561: entry point must be defined

I am working with Visual Studio 2012.
My Solution has 3 projects
projectA
projectB
projectC
and the Hierarchy is like
projectC depends on projectB which in turn depend on projectA. There is a main function in projectC and no main in projectB and projectA.
The errors that i am getting are:
error LNK1561: entry point must be defined projectA
error LNK1561: entry point must be defined projectB
I have tried changing in the
Configuration Properties -> Linker -> System -> SubSystem to Console (/SUBSYSTEM:CONSOLE) But the problem still persists
Help me out of this.
It seems, that you misunderstand the term "module". There is no such C++ project in Visual Studio; C++ projects may be divided into three categories:
Programs - compilation produces an exe file, which may be executed;
Static libraries - compilation produces a lib file, which may be included in another project and are linked during the compilation;
Dynamic libraries - compilation produces a dll file, which may be attached to your program at run-time and provide additional functionality.
From your description, you want the projectB and projectC to be a static libraries, but instead you created them as executable files. Run the new project wizard again and choose "static library" instead of "Windows application".
You can read more about static libraries in the MSDN library.
If static libraries are too heavyweight for your application, you may simply include projectB and projectC files in your project (optionally take care of namespaces not to confuse the names of classes). It all depends on how much functionality you plan to implement in these "modules".
set Properties -> Linker -> System -> SubSystem to "Windows (/SUBSYSTEM:WINDOWS)"
What's happening possibly, what was happening with me, is that when you switch your properties of your project to .dll from .exe, if you switch from debug to release or from x86 to x64, each time you do that it's switching you back to .exe. Each configuration has it's own properties.
So, go to Properties > Configuration Type > .dll
If indeed you want to make a .dll.
I'm going to guess you're using Windows for creating this project, for me, if I usually use SDL I get this error, all you have to do is type in this #include <Windows.h> that should fix it, if not then I'm not to sure how to fix that.

No Linker option in Visual Studio Project Properties

I'm trying to add a library to a Visual Studio C++ project, however, when I go to project properties I only have options for,
Common Properties
Startup Project
Project Dependencies
Debug Source File
Configuration Properites
Configuration
Why can't I see the linker options?
Updating answer for VS2012 to cover executable and libraries.
If your project is an executable then you need to navigate as such:
Myproject --> properties --> linker --> additional dependencies and add the dll or lib.
If you project is a library, there is no "linker" tab so you need to navigate as such:
Myproject -->properties --> Librarian --> additional dependencies and add the dll or lib
You are looking at the properties for the Solution.
You'll need to open the properties for the specific project within that solution.
Are you by any chance looking at a library project? Quoted from this answer:
A library is just a collection of objects, which by definition have not been linked yet. The linker is not used to create the library, so it makes sense that there would be no linker options for it.
In Visual Studio 2013:
Go to: Project Properties -> Configuration Manager -> General.
There, under Project Defaults, change the Configuration Type to either Dynamic Library or Application. Click on Apply. Then you should see the Linker tab added to the menu on the left.
If the Configuration Type (Configuration Properties -> General -> Configuration Type) is set to Utility, then no linker option will be available.
Either you are looking at the "solution" level or at a file level (e.g. main.cpp). Move to project level and you will see the Linker.

Visual Studio 2010 not autolinking static libraries from projects that are dependencies as it should be supposed to

Create a new solution with a C++ console command-line project
Create a new project, a C++ static library
Make the command-line project depend on the library
Make sure "Link Library Dependencies" is turned on in Configuration => Linker => General (it is by default)
Visual Studio will still not link the library.
How can I fix this? It worked in Visual Studio 2008.
This still works, but was changed in VS 2010:
"With VS2010, we stopped supporting project dependencies defining implicit references and we also introduced a new way of defining project dependencies at the project level. Since a project reference and a project dependency are close concepts, both applying to a project, it made sense to have them represented together, in a consistent way, in the project file. As you will see in the snippets below, the only difference between a project reference definition and a project dependency definition consists in metadata that defines the output assembly inclusion/exclusion into/from the main project link command line.
Although we did not remove the “Project Dependencies” dialog, we recommend defining new project dependencies via the “Framework and References” dialog. You need to set the “Reference Assembly Output” property in the property page UI to false for a project dependency and to true for a project reference."
Just right-click on the console project, select "Properties->Common Properties->Framework and References->Add New Reference" and add the static library project; also check that "Link Library Dependencies" is True on the right hand side. Seems to work for debug and release builds. You learn something new every day. ;)
They changed the UI for adding C++ project dependencies in VS2010, but oddly enough, without removing the old UI, or in any way indicating that it no longer works.
To create the dependency in VS2010, you need to use "Add New Reference" (can be found in project properties), and maybe also in the project's right-click menu (don't have VS here to check)
The old "Project Dependencies" dialog is basically broken now.
For MSVC 14 (2015 version) right-click on the project, then "Add->Reference..." and check all the needed dependencies.
Yes, it has changed somewhere between 2010 and 2015 versions. Fun!
And if you are looking to link a project that has resources in it - you need to specify the .res file directly in the list of linker input dependencies (project's properties dialog box) as it doesn't get picked up by the above configuration.
UPDATE
Still the same (new) behavior in MSVC 2017
I believe the old UI (dependencies) affects build order for Visual Studio, when building from within the IDE, for info. The new project configuration system embeds the references in each project file so that you can build from outside the IDE (whereas in previous versions, you could not, because you would not get automatic linking for dependencies, since dependencies were only done at the solution level).
There are also some issues with more complex projects in the new system; specifically, all resulting binary projects need to have explicit references to every dependent library to build correctly, whereas previously they could be effectively inherited from other dependent libraries. Same underlying cause, though.