I've used #jeff_t's solution as presented here however i encountered several issues.
I have a lib that holds a resource file and set as an external file, file name is
Other Files\myfile.exe
A quick look onto the rc file reveals the following line:
IDR_RES RES "Other Files\\myfile.exe"
Now, i set a DLL project which lays at the same directory level as the LIB and includes both resource.h(Read only symbol directives #include "../LIBProj/resource.h") and LIB.rc(Compile time directives #include "../LibProj/LibProj.rc")
Compiling the LIB goes smoothly, however, when i try to compile the DLL, which links against LIB, results the following error:
../LibProj/LibProj.rc(52): error RC2135: file not found: Other Files\myfile.exe
I do understand that once the linker tries to access additional includes from the DLL projects, it goes out off scope, how to i fix it?
Edit: if i give an absolute path as follows:
IDR_GNRC_RES_AGENT_DATA RES "C:\\Develop\\Code\\LibProb\\Other Files\\myfile.exe"
it works well
After many hours of desperate tries, i realized the solution was quite simple.
I had to use the following path:
IDR_FILE RES "..\LIBProj\Other_Files\\MyFile.exe"
So for both projects that would work. LibProj wont be affected, because we go to the parent directory, and then return back. and for the DllProj we go to parent directory which holds both Lib & Dll projects, and then enter Lib's directory.
Related
I am a C# developer, and spoiled rotten when it comes to references and dependencies. I am working on a small project now in Visual C++ (Visuial Studio 2017), where I want to use the libtomcrypt and libtommath libraries. I've created a small project and added the 2 projects to my solution:
I have also added my includes:
And I added the dependencies:
However, I still can't build:
Error C1083 Cannot open include file: 'tomcrypt.h': No such file or directory
I am not sure what else I need to do to get the references working and the code to compile. Any pointers is appreciated!
The error message indicates that the compiler can't find the file tomcrypt.h while compiling one of your source files. From the message I would guess that you have a line like the following in your source file:
#include <tomcrypt.h>
(...or perhaps with quotes instead of brackets.) From your screenshot I can see that you've added "...\repos\libtomcrypt-develop\src\headers" to your include path. Is the file tomcrypt.h found directly in that folder, or is it perhaps in a subfolder instead?
Your #include directive will basically append whatever path you give it to each entry in your include path when looking for the file, so if there are subfolders in between, you'll have to expand your #include directive to include those folders.
If this doesn't solve your problem, perhaps try posting the actual full path of where this header file exists on your filesystem, as well as your complete include path value! (The full compiler command from the build log would be useful, as well as the complete error message(s) related to this source file.)
Edit:
The original poster posted a separate answer indicating that the actual problem was that the Visual Studio Project Properties were set correctly, but that he was accidentally trying to build a different Configuration. :(
I was building the project under x86. Once I changed it to x64, it built just fine.
I'm new C++, I have a dll file called DiceInvaders.dll, in my project, I need to use this library, I'm using visual c++ 2010, I set the Linker Input as DiceInvaders.lib and DiceInvaders.dll, I also copied this dll file to my porject directory, I always got error in this line of code:
m_lib = LoadLibrary("DiceInvaders.dll");
assert(m_lib);
The error is assertion failure. How should I solve this? Thank you in advance.
First you cannot pass the DLL to the linker like you are, it is not a file type that the linker recognizes and cannot be linked that way. When you create the Diceinvaters.dll file the linker will create an import library with the same filename and the extension .lib. It appears this is already being done. That is the library file you should pass to the linker when building any application that uses it.
Second, the Diceinvaders.dll file must be accessible in the DLL search path. This varies slightly depending on which version of Windows you are using but is generally something like the following
The directory the program was loaded from.
The current working directory.
The System directory.
The Windows directory.
The directories that are listed in the PATH environment variable.
Placing the DLL in your project directory is not going to be enough. Instead you should place it in the same directory as the EXE file(s) that have a dependency on it.
I have a c++ Lib project StoreLib, and I have UnitTest Project where I wrote a unit test to test a functionality of class in StoreLib. StoreLibuses bunch of external dlls
My boostTest project compiles and when I run the exe, it complained about missing bunch of dlls, I pasted all of them in my bin folder. Then get this weird error
Store.UnitTests.exe - Entry Point Not Found.
The procedure entry point could not be located in the dynamic link library C:\UnitTest\UnitTests.exe.
First I am unable to understand why is it treating an exe file (UnitTest.exe) as a dynamic link library ? if I write a simple test i.e. Boost_Check(6==6) with out referring to any header file in my StoreLib it works just fine, though moment I refer to any header file from StoreLib it gives above mentioned error.
Any clue what I am doing wrong ? any help would be appreciated
it turned out that the one the external dll included was old, perhaps it was not finding proer entry point
can someone please help me to understand the process.
in c++ visual studio 2010
i have a visual studio solution (lets call it mysol)
i have a project built as a static library (let's call it staticprj)
staticprj needs to use a library from outside (lets call it ext.lib)
in the body of the source code of staticprj i include outside library header file with
# include extlib.h and make calls to some of its functions (let call them extfunctions())
i also include the the path to the header files location of the ext.lib.
the staticprj compiles okay without errors
the mysol also has another project which is a dynamic library (dynprj) and which depends on the staticprj.
also in the source files of the dynprj uses functions from outside library.
i have included #include extlib.h in the source code of dynprj.
i have included the path of the header files
i have attached extlib.h directly to the dynprj
i have also added ext.lib to the linker input (along with the path where the ext.lib resides).
i still get a lnk2001 error stating that extfunctions() where not found.
the whole structure (the mysol solution) compiles okay if i do not use ext.lib at all.
my question is how does the linking process works and what can i do to correct this linking error.
(note that without the presence of ext.lib my linking of the staticprj and dynprj is fine. my compilation works okay and my code works. i only get the linking error when i try to link another ext.lib to staticprj and dynprj and use functions from ext.lib)
thanks in advance.
I'm not quite sure it will work, but try putting the .dll inside your "mysol" debug folder. I had a similar problem couple of weeks ago when I had library compiled as .dll. I just placed that .dll within my debug folder and worked lovely.
I'll try to explain shortly what I want to do:
A project using a static library which have another one as depandency.
It produce a project called MyProject linking on MyLib1 linking on MyLib2.
Here is the compile order:
MyLib2
MyLib1 (linking to MyLib2)
MyProject (linking to MyLib1)
I'm using Visual Studio 2008 and I have some troubles at defining include.
When linking, I use the property "Additional Include Directory" (on project property C/C++ node).
This seems working between MyProject and MyLib1 but not MyLib1 and MyLib2.
For Exemple: I've a file in MyLib2 called foo.cpp; Using #include "foo.cpp" makes visual studio telling that foo.cpp is unknow (missing file or folder).
To ensure it's NOT a wrong path I gave, I've done many attemps like following: copy-paste the path shown in Command Line (used to compile the library) into win explorer: I well see the source code of my second library. I've remake the project many times and each times I used differents names (forcing me to pay attention to this) and everything seems well defined (but not "including").
The only way I actually find to make it works: using #include "c:\\foo.cpp" as include... Very nice for portability !
Here is a Zip of the Solution to test it yourself and tell me what's wrong: MyProject.rar
Thanks for taking some time to help me !
Lucyberad
First, never include *.cpp files.
Second, use forward declaration of your external functions:
void appellib2(void);
void appellib1(void)
{
appellib2();
}
Third, right-click each project in the Solution Explorer, and select "Project dependencies..." and set-up proper dependencies: MyProject -> MyLib1 -> MyLib2.
At last, in properties for MyProject, set up additional dependencies MyLib1.lib.
Now I can build and run your project without errors.
UPDATE
Never rename *.cpp to *.h just to solve linking problems. If you have a definition in your *.h file you will unable to include it twice or more.
Here is your project YourProject.rar.
I've changed .cpp to .h. I Know I've never to include a CPP file but it was for testing purpose.
I've added prototype of each function but it doesn't works better (It don't include the file mylib2.cpp, the prototype is better but not usefull in this test).
I've set up project dependencies. It still fail.
I've set up additional dependencies MyLib1.lib to MyProject (I think this was the next error I would be able to find, producing a linking a error).
With theses modifications, I still got include error mylib2.h: no such file or directory.
Here is the new archive: MyProject.rar
If you reach to get it working, can you make me an archive of the working solution?
Thanks,
Lucyberad.