QtCreator - Compiling issue - External source files - c++

I have a Qt project, accessing another cross-platform (boost) project on my disc. Adding the header includes does not seem to cause any problem.
#include "../../Visual Studio 2015/Projects/..." //Header file down the road
Adding existing source files to the sources folder in my Qt Project works also without a problem, the files are found and I can open them. I believe the files are not correctly compiled - if at all - as I get a linker error, telling me that %sourcefile%.obj could not be opened. (not created)
LNK1104: cannot open file 'debug\Error.obj'
I tried copying the content of Error.cpp into a new .cpp file created in the Qt project directory. After that the error message jumped to the next source file. I could now do this for all source files, but this seems to be quite... unhandy. Changes in the original project won't affect the Qt project then.
Does somebody know the problem / got a solution to it ?
I checked this question, answer and comments already, but that did not seem to fix the error or change anything.

The solution was quite simple and a little strange. It appears that something is causing an issue when using paths with spaces with Qt's include(...) and SOURCES in a *.pro file.
//This apparently works and source files are compiled.
include(C:/ProjDir/ProjName.pri)
//This works too, but the source files are not being compiled.
include("../../Visual Studio 2015/Projects/ProjDir/ProjName.pri")
Thanks to JKSH on the Qt-Forums and Sebastian for his hint using a .pri file.

Related

Visual C++ build produces an empty .obj while manual compile succeeds

I have a Visual C++ Professional 2019 Version 16.11.8 solution with 4 projects, one of them a GoogleTest project, others are libraries. It worked long just fine, but today it started complaining about 4 missing methods in a class. Those are in a separate .cpp file.
During build, it compiles this file, but the result is only 70 kB (should be 500kB) with no methods in it (examined with objdump). Unresolved references. When I compile the specific file using Ctrl-F7, then issue the build, everything is OK.
I've tried clean all, rebuild all, restart computer, delete all the Debug directories together with .vs, but nothing.
I haven't customized anything on that ,cpp file, at least not on purpose.
What can I do? Thanks in advance.
The cause was some misplaced header and source files. Header in source directory or the opposite way, I don't remember. Making order healed the project. Apparently I wans't careful enough during adding new files.
Make sure, that
Each header file gets in the project include directory.
Each header file is added via the new header template, and gets .h suffix.
Each source file gets in the project src directory.
Each source file is added via the new cpp file template, and gets .cpp suffix.

cxx1: c1083 error cannot open source file"..\test\xxxxxxxxxxxxxxxxxx.cpp" in visual studio 2015

I copied a project to some new location. But for "..\" the relative path is not changing. Then I tried to build the project with my visual studio 2015.
cxx1: c1083 error cannot open source file"..\test\xxxxxxxxxxxxxxxxxx.cpp"
First of all, in the same directory that contains xxxxxxxxxxxxxxxxxx.cpp, all other cpps all have been successfully compiled except 'xxxxxxxxxxxxxxxxxx.cpp'. This is quite strange.
I removed this 'xxxxxxxxxxxxxxxxxx.cpp' from the project. Then readded, but still did not work.
However if I copied 'xxxxxxxxxxxxxxxxxx.cpp' to e.g. user\Documents, and then added it again to the project. It worked.
Thus I guess this must have something to do with the length of my source code name and its path. ('xxxxxxxxxxxxxxxxxx.cpp' surely has a long name and the directory is very deep).
And secondly, if I use notepad++ to open myproject.vcxproj, the 'xxxxxxxxxxxxxxxxxx.cpp' appeared quite far behind in the compiling sequence, e.g.<ClCompile Include=, in the original directory. If I copied it to user\Documents, it's location will be raised forward.
So any explanation for such a phenomenon? And any suggestions to make it work without copying 'xxxxxxxxxxxxxxxxxx.cpp' to a different directory?

Adding libtomcrypt and libtommath to my c++ project

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.

Xcode - header files issue with .cpp file

I have imported my project from windows to mac and Is using xcode to compile the project.
I have managed to fix most error and bugs from the porting process but there is one bug/error I am unable to determine why its not working as it should. This probably due to my lack of knowledge of xcode but was wondering if anyone is able to help me with this problem.
The problem is this;
I have a two sub folders in my project, once called include and another called source. Of course include contains all the header files and source contains all the cpp files and such.
Example:
Root/
Include/
Header.h
Source/
test.cpp
Now in the build settings in the xcode project, I have added $(SRCROOT)/Include/ in the Header Serach Paths. So therefore I presume that xcode will include any header files in the Include folder.
So in the test.cpp class I add #include "Header.h". When I click build I get an error saying "'Header.h' file not found".
Im not entirely sure what I am doing wrong, of course I can do this for example - #include "../Include/Header.h" but that's going to be a pain going through all the cpp files in my project (which is a lot).
I was just wondering if anyone else came across this problem?
Thanks for reading.
In general you need to add the headers to the User Header Search Paths, which if you search the help in XCode will give you the format you need to pass the directory as.

Netbeans-specific C++ error "Undefined reference to XXX" - (Solution posted)

I wrangled with this problem for a good 5 or 6 hours, pulling my hair out until I finally found a solution. I wanted to post this (not sure if there is a specific place to post solutions to unasked questions) as a solution for others who may run into the same difficulty.
I am coding a C++ project in Netbeans 7.1.1 running on Linux Mint Lisa, and kept on getting an "Undefined reference to XXX" error when trying to use a static variable. Coming from a background in C# and thus not very familiar with header files and the like, I searched for hours expecting to find a problem with the way I declared my variable or my class. I couldn't find anything...
Go to your nbproject folder in the files explorer in Netbeans. Open up the configurations.xml file. Scroll down to the logicalFolder tag with the attribute name="SourceFiles". Make sure that all your .h and .cpp files are included as itemPath tags within the logicalFolder tag! Netbeans correctly added some, but not all of my cpp and h files, hence the problem. Not sure why there would be this inconsistency, as all class and header files were added through the same Netbeans wizard. Anyways, with the configurations file changed, the makefiles were then updated and written correctly on the next build and all functioned as expected. Hope this can help somebody!
Just to add more details to Levi's answer (for anyone newish to this like me), click the "Files" tab on the left of the screen, where your list of files and folders is. This gives you a different list of files than the "Project" tab does.
Expand your project folder if it isn't expanded already. One of the resulting folders is "nbproject." Expand the folder. This is where configurations.xml is.
In short:
Files tab > nbproject > configuration.xml
However, adding the .h files to configuration.xml did not work for me.
In my case, I only had to include the source files as #include lines within other source files to make it work ... I could compile the individual source files without error, but the project was another story. Once I added the #include lines in other source files that required certain methods to be found, then it all worked as planned. Hope this helps someone.