So I have some C/C++ library compiled into .a files. library is ffmpeg (52). Could any one provide me with detailed instructions on how to use it in visual studio 2008 (how to link it to VS so that compiler would find it and so on)?
This might be useful: From MinGW static library (.a) to Visual Studio static library (.lib)
Please rename your file from .a to .lib, and place it along with the source files of the project.
Now go to project's properties and in the VS C++ include directories add the path of the header/include files for that lib.
To use the symbols in a source file write
#pragma comment(lib, "your library's name")
Related
I want to use ch.h file from chibios in my project. The embedded project is created and is using HAL drivers for stm32. I want to find a way to add or import chibios library to the current project.
My question is that
how can I add these embedded libraries with lots of dependencies by visualGDB in visual studio?
Do I need to create .lib files of chibios?
What are the differences between C/C++ paths and linker paths?
Adding .a and .h files is enough or do I have to look for other files?
There are 3 ways that I followed and it wasn't successful.
I followed the link to add the paths.
The files that added to projects are libch.a and ch.h. It is called other header files inside ch.h. Then, I added the other header paths to C/C++ "additional include directories" too. After I added the third header file, I got the error "redefinition".
The second way, I wanted to use vcpkg, a library manager. But the chibios library wasn't available in vcpkg.
One another way is to add libraries in standard libraries without adding any paths. But how can I find standard libraries? If the location is in the compiler (gcc-arm-none-eabi), the chibios package was added, but it still wasn't detected in visual studio.
I really appreciate it if you know any tutorials or ways to add chibios in the visual studio
I download pthread-w32-2-9-1-release.zip, unzip it and use Prebuild/include lib and dll with VisualStudio2013.
I set up a VC++ empty project "helloc" with main.c, then write a simple example with pthread_create pthread_join functions.
This is my configure:
Properties->C/C++->General->Additional Include Directories, add "F:\pthread_win32\include"
Properties->Linker->General->Additional Library Directories, add "F:\pthread_win32\lib\x86"
Properties->Linker->Input->Additional Dependencies, add "pthreadVC2.lib"
And it's successfully build, but when I click "Local Windows Debugger", the console break with "helloc.exe error because cannot find pthreadVC2.dll".
Then I copied pthreadVC2.dll to helloc/Debug/, same directory with helloc.exe, finally it's working.
But I don't know why the pthreadVC2.lib and pthreadVC2.dll are both required by helloc.exe. Is it a must that both lib and dll being used in VisualStudio ?
If only one of them (pthreadVC2.lib pthreadVC2.dll) is enough to support helloc.exe, how can I specify which one (dll or lib) I want to use in VisualStudio with helloc.exe ?
And I don't want to put all pthread libs and dlls into "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC", I want to know how to configure manually.
AFAICT, the pre-built library is just an import library for the DLL. (Allowing you to link against the DLL, hence required)
If you want to link statically, you'll have to rebuild the library yourself. See the README file for more information.
I am a beginner on C++ and trying to learn about including libraries, and I haven't found documentation about it.
What are the ways of including libraries to a C++ project (Visual Studio). How do I implement them and which is the best way?
I was trying to include the SQLite library to a project. I tried to:
Include the header file in the include folder of the Visual Studio installation folder. It did appear in the External dependencies of my project, so I can do #include <sqlite3.h> without problems, but I don't know where I should put the implementation (a C file) and how to link it (is it in the linker>Input>Additional dependencies?).
Is it necessary that in order to include a library the file should be a .lib? Because I can't find the .lib for SQLite 3, do I have to include it in the lib folder of my Visual Studio installation?
Note: I am interested on the management of including a library in general. The SQLite 3 part is only because I took it as an example in order to learn how to add them.
A library is added in two steps
Adding headers path to the project
Adding .lib reference
In the first step, you must specify in the project where library headers are header. Usually, the path is specified in the project properties -> C++ -> Additional include directories, and them including files with relative paths.
In the second step you must specify in properties->linker the path where libraries (.lib) are located and the name of the library. With this Visual Studio is able to link the project properly.
go to project add existing item you must then select from the browse screen the .lib file you wish to add. and BINGO it is there!
best wishes
david
I'd like to use a library I've compiled using Cygwin GCC (.a) in a Visual Studio C++ project. When I include headers from the library in VS, the ext/hash_map header is missing. Is that a header file I can just add and replace with hash_map, or is it all together hopeless (because the library doesn't make heavy use of hash maps)? Moreover, is it ridiculous to hope VS can use the .a library? Thanks!
You cannot mix GCC generated .a files with Visual Studio.
I'm using Visual Studio C++ 2005 on Windows XP.
I have created a DLL shared library using Visual Studio C++ 2005.
However, I am not sure how to link it. Normally I have just created the static libraries (*.lib).
Do I link the same way I would when linking a library. By using the properties C/C++ and linker general properties and selecting the path for the headers and library paths?
Many thanks for any advice.
When you create the DLL there should be a .lib file created for the purpose of dynamic linking. You can use these just as you would static .lib files.
This article explains Windows dlls well.
The .LIB file associated with a DLL
describes what (exported) symbols are
present in the DLL, together with
their locations.
To put it simply:
When you link: you Need Lib, not DLL
When you run it: you need dll, not lib (Put the DLL with your executable)