C++ Build library and link it - c++

I'm trying to write a program that use FANN Library: http://leenissen.dk/fann/wp/
I downloaded the source code, I opened the .sln project and compiled it. Now: what I have to do? I tried to create a new "console application project", I included the main header
#include "src\include\fann.h"
(I previously copied the src folder in my project folder)
I went on: Project->Properties->Linker->General and I pointed "directories library" to the "bin" folder in which VS compiled the .lib but I still have the error "unresolved external symbol" (the error, of course, is related to some functions that I'm calling in my code). I really don't know what to do, it's my first time I try to do something similar, I think I'm missing something important here...

Try adding your .lib into Project->Properties->Linker->Input->Additional Dependencies.
You'll see combobox, in it 'edit...' and then you'll, get a window where you put the name of your library file. You have to have the library directory set as you did. You have to research what is the name of your library file.
In this forum, they are using 'libfann.lib' name.

Related

Debugging static library function cpp file in Visual Studio

Being new to making/using libraries, I followed a simple tutorial to build a static library in Visual Studio (2022). I made a solution with 2 projects in it. One that builds a library and one that uses the library. It worked. Then I made an independent project / solution to see if I can use this library independently from the original solution/projects. I put the lib file and hpp/cpp file into new separate folders and set these folders in project properties (Additional Include and Library Directories + the .lib file).
Problem: I could use the functions from the library in this new project but when I tried to step into it with the debugger, the cpp file it stepped into was from the original project. (that's what the path showed anyway.) When I renamed the old project and tried again, VS complained that the file directory has changed and asked me to set the path to it. I did set it to the newly made directory with only the hpp/cpp in it and it was fine. I made another new project for using the library and tried the whole thing again and then the debugger simply could not step into the function, it stepped over it.
My questions: what was going on here? how did the debugger find the original cpp file when Im positive I did not set that path anywhere in the new project? and how do I debug a static library then? Is putting the cpp file next to the header in the include directory not enough?

How to include SFML source code into my visual studio 2017 c++ project and compile

I have been programming a game in c++ using the sfml library. However, I would like to adjust some of the code of that library, and use that altered code in my project.
So instead of linking the dll I would like to add the source code and then play with that source code. (e.g. for speed optimization).
I know that doing something like that is generally speaking a bad idea. Howeover, I want to learn by playing around a bit and trying different things.
So how would I add the sfml source code to my c++ project in MS visual studio. Note that I am a total noob. I already tried adding the sfml folder that I downloaded from git in the project properties page called "Additional Include Directories", but i am getting errors, of the form "Cannot open include file: 'SFML/Graphics/GLCheck.hpp': No such file or directory" so I guess that i have not yet done enough.
If you want to modify the source code in the library, all you'd have to do is just navigate to where you have SFML installed and go into the code files with a text editor and edit them.
Then, you could link the library to your VS project the same way you would normally but that library is now modified by you.
Seeing as you have a search directory issue already in VS, you must fix that first. Fix that and then go and modify the library's .hpp, .h, .cpp, whatever files in-place.
To fix the search issue.... I don't use VS for graphics, I use CodeBlocks so I am not sure about their GUI to link libraries and change search directories... but, find out where you installed SFML. Check your /usr/include/, it's probably there. Specify that path in the search directories. Just go and find where that GLCheck.hpp file is located. For Example: Say it's full path is /usr/include/SFML/Graphics/GLCheck.hpp... then /usr/include/SFML/Graphics/ or just /usr/include/ (VS might handle it recursively) needs to be in the list of SEARCH DIRECTORIES.

VS2012: Program can't start because "libvorbisfile.dll" is missing

I've got a project and I'm trying to make it read a .OGG file.
I've downloaded the libogg and libvorbis from here, compiled them (had some trouble figuring I had to build libogg first), then got the following files:
libogg.lib
libogg.dll
libvorbis.lib
libvorbis.dll
libvorbisfile.lib
libvorbisfile.dll
I dragged all of them in my project's Libraries folder, already added to the project, and included them in the Linker->Input (only the .lib).
Next I copied the headers to my project's Includes folder, also already added to the project, with the files:
ogg/ogg.h
ogg/os_types.h
vorbis/codec.h
vorbis/vorbisenc.h
vorbis/vorbisfile.h
Then I added some code, and I get the error "The program can't start because libvorbisfile.dll is missing from the computer."
And I'm pretty sure the file IS in the Library folder and properly defined in the properties.
Did I do something wrong along the way?
How can I figure what is wrong so I can fix it?
I already tried putting the .dll in the project's folder and in the Windows/System32 folder as well, didn't work.
The library folder is fine for your .lib files, but it's looking for the .dll at run time, which your project settings have no effect on. Windows looks in a few places for a .dll, but the easiest way to get your program to run is to put the .dlls in your working directory, which is where ever you run your executable from (probably the same directory as the .exe file).

Creating .dll from .h and .lib in Visual Studio 2010

I am trying to create a .dll file from my header and library files that I got from tngaming for their gaming vest.
So far I've been using this guide, but instead of creating a new header file I added my tngaming file to the folder where the header files are located and then added it to the folder inside visual studio by using "Add existing item."
Afterwards I used the properties -> linker -> input where I added my lib file which also seems to work fine.
Then inside the tngaming.cpp i added the line
#include "tngaming.h"
Now it is possible to build my .dll, but it does not work. When I look at it, there are\ lines that says stuff like "stack memory corrupted" and so on.
Am I creating my .dll correctly or am Idoing something wrong?
How do I actually create my .dll?
Ended up finding a guy that had the same problem as myself and fixed it so problem solved. Anyone else getting into that problem can look at
http://waterhobo.com/?p=28
Thanks for the help though

Cannot link to lib file after upgrading to VS10

So I imported this VS9 solution into VS10 and VS10 would convert the whole thing into its new format for solution and project files. However, now it is giving me linker errors.
One project, a native C++ project, is using a set of header files and a .lib file to link to some external library. In the project, this library is specified by being put into a "Library" folder in the project. In VS9, this works fine, in VS10, it fails. The same lib is linked, however, when put into the "Additional Dependencies" setting in the Linker Input panel of the project's options.
I know the technique to drop lib files into the project for more than a decade. Has this stopped working with VS10?
No ,that still works in VS2010 (just tested it to make sure)!