QT : "this file is not part of any project" - qt-creator

I created a project folder (test1), then when creating the C++ source file main.cpp, it says that this file is not part of any project although i created it in the same project test1 by doing :
File -> new file or project -> C++ -> C++ source file.

Open the .pro file and check if something like this is missing:
SOURCES += main.cpp
(with proper path if needed)
Also it seems you did not configure the project. In "projects" you should choose a kit to use when building. This may also be a cause of the warning.

For a .creator project (without Qmake) deleting the .creator.user file while Qt Creator is closed helped in my case.

Related

Have Intermediate CMake Files Appear in the IDE

I am developing a system of build scripts for CMake and have an issue with wanting to have intermediate CMakeLists.txt files appear in the IDE for easier search and edit.
I have a main CMake file that includes a directory that includes several subdirectories for libraries.
CMakeLists.txt
--- SubProjects:
-------CMakeLists.txt
-------ProjectAFolder:
----------CMakeLists.txt
-------ProjectBFolder:
----------CMakeLists.txt
-------ProjectCFolder:
----------CMakeLists.txt
In the SubProjects folder, the CMakeLists.txt is very simple and just includes the subproject folders one after the other:
SET(SUBDIRECTORIES ProjectAFolder
ProjectBFolder
ProjectCFolder )
foreach (subdirectory ${SUBDIRECTORIES})
add_subdirectory(${subdirectory})
endforeach ()
However, when I generate this in XCode or Visual Studio, the IDE does not include the intermediate CMakeLists.txt file anywhere because it does not belong to any individual library or executable target. What is the best way to include this somewhere so it appears in an IDE?
Depends on where you want the file to show up, since it doesn't belong to any target. You can simply add it to any existing target (just as you do with source files) or you can create a new custom target.
add_library(AnyExistingTarget <other source files> SubProjects/CMakeLists.txt)
Or create a custom target:
add_custom_target(MyIntermediateCMakeFiles SubProjects/CMakeLists.txt)
For Visual Studio, you could also use the built-in support for cmake. It will display the source tree in the IDE without any extra work.

Add shared library project's dll file to executable projects path at runtime in Eclipse

I'm using Eclipse Juno for c/c++ under Windows 7. I've created a shared library project and an executable project. I've added the shared library project as a reference in the executable project via:
executable project's properties -> C/C++ General -> Path and Symbols -> References -> check the shared library project
All this works great at compile time, I can include my shared library project's class in the executable project, and use it etc.
However when I try to run the executable project in Eclipse, I get nothing. No error, no console output. After some googling I've discovered a similar issue here:
http://www.eclipse.org/forums/index.php/m/650331/
Apparently adding the shared library project to the executable project in Eclipse, as described above, does NOT also add the dll file to the executable (.exe) file's PATH at run time inside Eclipse. As an analogy with Eclipse for Java: if you have a Java JAR project A and another Java JAR project B, by making a reference from B to A in Eclipse, B's compiled jar file IS added to A's class path when running project A inside Eclipse. I thought it would be similar with Eclipse for C/C++ but apparently it's not.
Sure enough, if I manually take the .exe file and the .dll file, place them in the same folder and run the .exe, everything works ok. Also if I copy the .dll file in to Eclipse's compilation directory for the executable project, I can run the executable project from Eclipse and it's ok.
My question is then, is there a way to have Eclipse add that shared library project's dll file to the run time when I'm telling it to run the executable project? The discussed solution in the post I link to above is to manually add the shard library project's compile directory to the Eclipse's run configuration for the executable project, namely, to add it to the PATH variable there. But I find this cumbersome and not portable, if Eclipse is managing both projects it should be able to pass all that's necessary to the run time.
Well, I've went with the manual adding of the library project's dll to the excutable project's path at run time. I did find a way to make it more portable and project location neutral (i.e. if you move both projects' source folders to another machine, and reopen them in Eclipse there, it should still work):
right click on executable project -> Run as... -> Run Configurations
in the Environment tab click "New..." to add a new environmental variable
Name your variable "PATH" and give it a value similar to this:
${env_var:PATH};${workspace_loc:/cppAStar/Debug}
where:
${env_var:PATH} is Eclipse's way of saying "get the already existing value of the PATH environmental variable as declared in Eclipse"
the ";" is to separate the exisitng PATH entries from the new one we're about to add
${workspace_loc:/cppAStar/Debug} this tells Eclipse to get the location of the workspace project named cppAStar (here cppAStar is my shared library project) and then the "/Debug" refers to where this particular project creates the .dll file when it's built.
Issues that I couldn't figure out:
the "Environment" tab in "Run configuration" has an option called "Append environment to native environment". I thought that by checking this I'd only need to add the location of the .dll dir in the PATH variable I declare here, and it will be appended to the existing PATH. However I've not managed to make this work, hence the manual re-adding of all the existing PATH before appending the new value
Unfortunately that solution does not work for the debugg configuration. See Bug 338420 -Launch configuration's Environment tab variables are not passed to the gdb process itself.
Is there a way to solve this problem for debugging? I mean except from doing post-build steps like:
cmd /c copy "${BuildArtifactFilePrefix}${BuildArtifactFileName}" "${WorkspaceDirPath}\bin\"

Missing header files for VTK

I installed Visual Studio 2010, Qt and Cmake. I configured them. Then I wanted to test by an example code. However, the program cannot find the header files. I searched on the internet and found that there might be a problem with the PATH.
Then, I followed this way that results in failure:
I wrote each folder name separately by putting semicolon between them to
Project > Properties > C/C++ > General > Additional Include Directories.
In this way, program found the header files but it gave me an error LNK1104. I think it happened because the Path for file name expands to more than 260 characters. I learned that from this site.
I tried to find one folder that I can write to PATH. I think it's lib file. But I could not find it.
what should I do to fix this problem?
Setting two values in visual studio will remove this error.
Go to Properties of the project -> C/C++ -> All Options -> Set the correct value for "Additional Options".
Go to Properties of the project -> Linker -> Input -> Set correct the value for "Additional Dependencies".
If you create the project using CMake, then these values will be setup automatically.

When trying add existing project to solution, a project in a different path is referenced

I am doing some housecleaning with our VC++ project structure and I had the following weird directory setup. In one folder, called "USBAScan", I have a Visual C++ project file, named "USBAScan.vcxproj". USBAScan has a subfolder that is also called "USBAScan". It also has a VC++ project file named "USBAScan.vcxproj".
My VC++ solution references a project named "USBAScan.vcxproj". Its project file property is "USBAScan\USBAScan\USBAScan.vcxproj". I remove this project and delete the project file USBAScan\USBAScan\USBAScan.vcxproj. In the solution I try to add USBAScan\USBAScan.vcxproj. I get the following error message:
"The project file USBAScan\USBAScan\USBAScan.vcxproj has been moved, renamed or is not on your computer".
Although I'm trying to add USBAScan\USBAScan.vcxproj, the solution is trying to add USBAScan\USBAScan\USBAScan.vcxproj. Why would it behave this way?

XCode 3.1.2, header file not found

I have been trying to build a code that has dependencies with other header files that are not in the project directory. I added the paths to these header files in both HEADER_PATH and USER_PATH. However, I still see error while building. It says that the file is not found. I verified that the file exist in the path added to the header search path in project settings.
How do I make sure that all my header files referenced in the project is included and the paths are being picked by Xcode during compilation?
I tried copying all the files to the project with no luck. This is the first time iam using Xcode, so its kind of frustrating. Iam a linux guy and comfortable with make files. Is there a Make file for xcode which i can modify to include the header file directories.
You might want to check the order of your source files in your target's build phases to ensure that your dependencies are compiled before your source files that reference them.
Select your project in the Project Navigator.
Select your target.
Click on the Build Phases tab.
Click on Compile Sources to expand the section.
Drag the dependencies to the top of the list.
Are you sure you spelled the header file name correctly ? Is the case correct ? Did you use user quotes "" rather than system quotes <> ?
Assuming you've checked all the obvious things such as the above then one other thing to try is to quit Xcode, delete the "build" folder in your project directory, and try again - sometimes the build folder gets in a pickle internally.

Resources