Linking .lib and .h files (OpenJDK 1.8) - c++

I have a project, that includes jni.h and jvmti.h files
here
theese files are stored in jdk8 folder (already installed on my pc)
here
but the main problem - i dont know how can i correctly link jdk libs and .h files to my visual studio prj

I suggest you could follow the following steps to link the static library:
1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)
3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)

Related

How do I add a library from another branch in VS

My task is to make myself familiar with a given code which also includes a dll and a lib file. I tried the advice given in this post : How to add additional libraries to Visual Studio project? but apparently the lib file I included cannot be opened. I tried to include it at the linker, as suggested in the other post and then tried the file name as well as the entire path at "additional dependencies" but neither of them worked. Any suggestions?
For more details about how to link the .lib, I suggest you could follow the following steps:
1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)
3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)
You also need to make sure that you add the configuration properties to the correct build target and platform for your code.
For example:
I suggest you could select "All Platforms" for the platform and select "All Configurations" for the Configuration when changing the properties.

VS2019 linux cannot find additional dependencies

I am doing a remote C++ build from VS2019 to a machine with Centos. When I input the library to the option additional dependencies, the vs2019 always shows g++ : error : libTest.a: No such file or directory , the file libTest.a is a library I wrote to test my solution.
You should properly configure you VSLinux environment.
First, add additional include directory on Properties -> C/C++ -> General -> Additional include directory. Add paths of directories for additional header files for your library.
Second, add additional library directory on Properties -> Linker -> General -> Additional library directory. Add directories where your static/shared libraries are.
Third, put your name of libraries on Properties -> Linker -> Input -> Library dependency. Add the name of your library. Remember, you should remove prefix lib and the extension of the library.
The exact name of the option may differ since I'm not using VS2019 in English.

Visual Studio - static library won't link

I created a static library (designated A) in Visual Studio that includes some header files from another library (designated B). Because that is a static library I didn't need to worry about the .lib file from A. When I created a console app (designated C) and added the .lib and header files from B as well as the header and .lib files from A. When I try to compile C it comes up with unresolved externals, not related to A, but to B.
I created two more test projects, a static library and a console app. The static library still used A and the console app still used A and the new static library, and it managed to compile fine, even without the header files of A.
I've run through all differences and I can't see any that would stop C from compiling. The only difference is the folder the projects are stored in. I have double-verified the locations of header files and .lib files and they are all there. How would I go about fixing the LNK2001 errors?
EDIT: I realised my post doesn't make much sense but when I try to use my library in another project it won't link at all and I can't see a reason why.
To link with a .lib file, you just need to:
1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)
3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)
If this issue couldn't be resolved, I suggest you could refer to the Doc:Linker Tools Error LNK2001

Cannot open lib unless I manually copy it in my project

When trying to import an external library from a different drive I keep getting error LNK1104 "cannot open foo.lib"
I set up the correct paths in:
Properties -> Configuration Properties -> VC++ Directories -> Include Directories
Properties -> Configuration Properties -> VC++ Directories -> Library Directories
Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories
Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories
And the correct .lib filename including extension in:
Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies
This still gives me the error and the only way I have found to fix it is to manually copy the .lib (or .dll) file inside my project, by copying it the linker can find it and link it correctly.
Pretty much all the questions I have found on SO say to set the correct paths and filename of the .lib like I did, why this is not working and I have to directly copy the .lib file inside my project directory to have it work?
According to the Error LNK1104, as far as I'm concerned the cause of this issue is that the compiler couldn't search the directory of the .lib file.
To fix a path issue, we should verify that the LIB environment variable is set and contains all the directories for the libraries you use, for every configuration you build. In the IDE, the LIB variable is set by the Library Directories property on the VC++ Directories Property Page.
If the static library is not part of the solution,In the VC++ Directories property page, I suggest you should try to add the path to the directory where the .lib file is located in Library Paths.
For more details ,I suggest you could refer to the link.

Cannot open file 'glew32.lib'

I have downloaded glew-1.9.0.zip built the projects under C:\glew-1.9.0\build\vc6 and C:\glew-1.9.0\build\vc10 and am unable to build after setting visual studio's paths to the glew include and lib paths. The lib directory does NOT have glew32.lib after building glew. What must I do in order to be able to build an opengl project?
You could download binary pack (32 bit or 64 bit) and find already compiled version of glew32.lib in lib folder and all includes?:)
In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.
Also you must include #include <GL/glew.h> in your sources;
For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;