How can I include Lua library in VS 2008 - c++

I'm not sure about this location.
In Properties > Linker > General > Additional Dependencies
I have to include some library in Additional Library Directories, haven't I?
or I have to install some program in my computer?
The problem is I can't to use luaL_dofile, but I can use it before my computer was formatted.
That's why I'm not sure about library. I compile and run my code after my
computer was formatted suddenly. I'm pretty sure that my code has no problems
because it can run before my computer was formatted.

Well, then, obtain the library from where you get it. Place it in some place that you know it will not be moved (or install it if an installer is provided), and do this:
Select menu item Project -> Properties -> Configuration Properties -> Linker ->Input.
Now add the name of the library in the "Additional Dependencies" edit control.

You need to do two things:
Add the library directory to Libraries directory
Add the library name (without path, but with extension) to Linker->Input->Additional Dependencies

Related

How do I add a library to my NetBeans C++ project?

I want to use the boost library in order to use some of its functions but I don't know how to do so and cannot seem to find an answer.
I'm currently using NetBeans 8.0.1 ,any help is appreciated.
You have to add two things:
(a) Library header
Go to …
Project Properties -> C++ Compiler -> Include Directories
add the header's directory path there.
(b) Library binaries
Go to …
Project Properties -> Linker -> Additional Libraries Directory
and add the directory path- that's where your library binaries are.
Next add your library at:
Libraries.

Visual Studio 2012 - error LNK1104: cannot open file 'glew32.lib'

I am having issues compiling a basic openGL program on VS 2012. I get a build error upon compiltation giving me:
1>LINK : fatal error LNK1104: cannot open file 'glew32.lib'
I followed the instructions given to me by the documentation for GLEW.
In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.
Also you must include #include in your sources; For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;
C/C++ Tab -> General -> Additional Include Directories - Add lib folder there
I have also added the glew32.dll onto my Debug folder within my project folder along with the executable. So far I keep getting this error.
If you need any more further clarification of the steps I have done please don't hesitate to ask
In all honesty, there is no real benefit to using the DLL version of glew (short of reduced executable size, but this hardly matters on modern Windows PCs).
It is not like you can simply drop a new version of the DLL into your application and use extensions that you never used before. Likewise, bug fixes are so infrequent/unnecessary with a library that basically just parses the extension spec. files that using the DLL as a means of fixing extension loading bugs in shipped software is also not practical. Statically linking to glew (this means glew32s.lib) makes much more sense in the long run.
The static linking library is also more portable on Windows, it will work with MSVC and MinGW (whereas the DLL library only works with MSVC). Link against glew32s and put that in whatever directory you decided to use for additional library dependencies.
Here is a sample solution configuration for a project I wrote that uses glew. I have established a convention for this particular software where compile-time dependencies are stored under platform/<Subsystem>. Thus, I have glew32s.lib (32-bit) and glew64s.lib (64-bit) in ./Epsilon/platform/OpenGL/glew{32|64}s.lib
Steps to Use Classes form another project (Add header and solver linker errors)
To be able to add the header from another project, first go to "Properties > c++ > General > Additional Include Directories" and add the directory that contains the header. Now you will be able to add the header of the class from the other project, but running the project will still cause Linker Errors.
Add __declspec(dllexport) before the class you are using for the other project. This can be added in the header file of that class. This should be added right before the function or variable or class name. Now you will get a lib file. (if placed in wrong place, you can get this warning: https://msdn.microsoft.com/en-us/library/eehkcz60.aspx)
"Properties > Linker > Additional Library Directories". Specify the location of the lib file that is generated.
"Properties > Linker > Input > Additional Dependencies”: Add the name of the lib file.
This sounds like the library has been specified as a dependency, but the linker/additional search path(s) has not been set to include the directory where the library is located.
This may help.
It happened to me under this situation, I clean the solution and build it again, then many errors like LNK1104 occur.
After trying to restart IIS, I build solution successfully without LNK1104 errors. I do not know why, but restarting IIS takes much more time than normal, so I guess something is used by other IIS worker process.
Just give a shot to see if this magic happens on you.
This question is old and marked solved, but I had a similar problem symptoms with a completely different solution. So just in case anyone else stumbles in here:
It appeared that because I had 2 projects under one solution (a dll and an exe), the building order was mixed (from the output window):
1> Rebuilding project1..
2> Rebuilding project1..
1> file1.cpp
2> file1.cpp
and so on. By the message you copied, it appears you too have more than one project under one solution. One project was looking for the *.lib file that the other build hadn't created yet.
Solution:
Right click on "main" project -> Build Dependencies -> Project Dependencies.. -> Mark which project the main one depends on.

cannot open file 'SDL2.lib'

I am trying to open sdl2 in my project on Visual C++ 2012 but i keep getting this error:
error LNK1104: cannot open file 'SDL2.lib'
I added the additional libraries and include folder but no luck..
I added the link to the libraries through the linker but i get the same error..
what should i do?
I'm referencing VS 2010, but I've read before that some people have had errors when using the VC++ Directories in their project properties as opposed to the Linker->General->Additional Library Directories.
Unfortunately, there really isn't much more to do besides making sure the directories are linked properly. There really is only one answer to this question. It also may depend on the download of SDL you chose, are you donwloading the Development Library as opposed to the binary?
Watch this video https://www.youtube.com/watch?v=or1dAmUO8k0.
In summary, you want to add the path include folder here: (configuration properties> C/C++ > General> Additional Include Directories),
and add the path of the lib folder here: (configuration properties> Linker > General> Additional Library Directories)
and finally, link .lib file in: linker > input > Additional Dependencies.
It seems like you didn't add your library directory path in VC++ Directories/Library Directories.. You have to link your library directory path (Where you have save you libraries of SDL) in your program. After adding, it will definitely work
I would like to add for others experiencing this problem that its an easy mistake if you are using the Development Library to link to the lib folder. SDL needs you link to either the x86 or x64 folder in the lib folder.
If you run or compile your program before you make those required changes of SDL then you will get this error always.. so first add a c++ file then make those changes and then write something and try to run ..this time it will never give this error
It seems like VS can't find the lib files. There are two ways you can do this. One is to configure the appropriate directories in VS as TwinkleBearDev's article shows. Another is to put the libraries directly where VS would look for them, as my article shows. I don't know if the folders for VS2012 are the same though - might be slightly different.

Add library to C/c++ eclipse indigo project

I am trying to add a library to C/C++ project in Eclipse by the following procedure:
Properties->C/C++General->includes (within includes specifying the folder in which the library is kept).
Properties->C/C++General->Library Paths (Specifying the library paths of .so and .a files)
Properties->C/C++General->Libraries (Specifying adding paths of .so and .a files)
But when I build the project,it is not able to find the path of header files that I am including in my project.
Can someone please tell me where the error is?
A similar question was posted here. You need to add the libraries in the Properties -> C/C++ -> Build area, not the General area.
Hope this helps.

Eclipse C/C++: Using static/shared library project in executable project

I think the title almost hits the point..
What I am trying to do is write a server. Here is the thing:
I want to separate separateable parts of the server into different projets. For example I wanted to create a Project "ServerNetworkStuff" and "ServerGameLogicStuff" into two projects which are static or shared libraries..
Now I want to create another Project "Server" that uses these two Projects as library.
Eclipse Projects:
- ServerNetworkStuff (static library)
- ServerGameLogicStuff (shared library)
- Server (using ServerNetworkStuff, ServerGameLogicStuff)
Is that even possible? Or is there any equivalent solution which doesn't force me to reinvent the wheel?
Thank you for your help!
EDIT:
If I add a reference to the active mode under "Project > Properties > C/C++ General > Paths and Symbols > References" it doesn't work. The compiler can't find the header files.. if I add the path to the header files I get "undefined reference" errors.
PARTLY SOLUTION:
*Okay it compiles now... but execution doesn't work at the moment..
What I did was first creating my projects "Server" (executable) and ServerNetwork (shared lib). After adding a ServerNetwork reference to Server there were a few things to do left.
I had to change my includes from
#include <include/ServerThread.hpp>
to
#include "ServerThread.hpp"
without meaning any shared libraries I am using in the project. Just changed it for the references of my own classes.
In my project Server that wants to use ServerNetwork I needed to add -lServerNetwork and -fPIC as parameter for g++.
And additionally the folder which the .so-file contains must be added to the library path (which Eclipse should do automatically if you add the specific project as reference).*
The Reference in Eclipse only works with open projects. I found the fastest way is to add or symlink the headers needed in the system path (/usr/local/include or similar) or just add the path to it, and doing the same with the library.
If you don't want to do that (which should be the best option), you still can add includes and libraries:
the -I path in Project Properties -> C/C++ General -> Path and Symbols -> Includes,
the -L libs' paths in Project Properties -> C/C++ General -> Path and Symbols -> Library Paths,
the -l libs in Project Properties -> C/C++ General -> Path and
Symbols -> Libraries.
Or by hand: the -I path in Project Properties -> C/C++ Build -> Settings -> [CGG/C/C++] Compiler -> Includes, and the -L -l libs in Project Properties -> C/C++ Build -> Settings -> C++ Linker -> Libraries.
Inclusion
Now you can #include either with <> or "" syntax (is a good practice to reserve the former to system libraries).
Iussues
You should have execution problems if you don't move/copy/symlink the libraries in default paths, for example with OSX, the solution is to export the non-default path just before execution (e.g. export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/non-default/lib/path for OSX).