Qt error: LNK1181: cannot open input file 'debug\main.obj' - c++

Qt creator was working well, but suddenly shows a problem error: LNK1181: cannot open input file 'debug\main.obj'.
This problem shows always with any type of application either GUI or console.
I've uninstall the Qt, and install again, but the problem still exists.
I did not do anything in the Qt creator settings, I left the default settings.
The following application is simple console application occur the same problem in it.
//main.cpp
#include <QCoreApplication>
int main(int argc, char *argv[]){
QCoreApplication a(argc, argv);
return a.exec();
}
Note: I'm using Qt 5.1.1 for Windows 32-bit (VS 2010, OpenGL).

This problem also occurs if the path of your project (name of any folder) contains a white space.

This problem occurs also if you have in the .pro or .pri files something like:
HEADERS += \ \
or
SOURCES += \ \

Okay, we finally have a real answer for this generalized problem instead of the OP's typo problem if that didn't unblock you either.
Actual Problem (black-box perspective): The "Build directory" auto-filled entry breaks for projects inside whitespace directories. Qt Creator actually prohibits you and tells you not to use whitespace when making new Projects. You can still close a new project and re-name it to add whitespace, and Qt Creator will handle it gracefully. If you copy the build directory, even with whitespace in it, and paste that into the field replacing the broken auto-generated path (mine was using relative paths) then JOM will start working correctly, as QMake does not generate any errors. I can't speak for other Make tools.
Make or clone down your project with whitespace
Load it in Qt Creator
Run QMAKE
Select the "Project" button on the left-hand side
Make sure you're in the "Build" tab
Select "Browse", and then re-select the shadow directory QMAKE made
That should unblock you if it wasn't a simple issue for deleting the old QMAKE-generated folders, which is the most common problem people face with this specific error while developing within Qt Creator.

I got the error because of this:
HEADERS += \ \
$$PWD/QOakTreeViewRecursiveModel.h
instead of:
HEADERS += \
$$PWD/QOakTreeViewRecursiveModel.h

What worked for me:
Close the Qt Creator
Delete the [filename].pro.user file in your project directory
Open the project again and let Qt configure itself
Generally whenever I encounter an error like this, this is one of the first things I do as it solves a lot of problems with Qt.
Edit: This will of course reset your project build location.

The problem has been solved.
The cause of the problem was when creating a new project (GUI or Console), all source files that belong to this new project take a wrong extension ex: main.cp, but the correct extension is supposed to be ex: main.cpp.
And when changing all the source files extension from .cp to .cpp worked fine.
Or change the default source file extension from [Tools -> Option -> C++].

hmm If I remember correctly when I faced this kind of problems using your similar setup (QtCreator and Windows) running QMAKE & rebuilding the project again helped me solve this linker errors.

Run Clean and qMake and rebuild.
I has like this problem and this helped me.

I solved the problem by removing the big path and space names in the directories.
Try to create a folder in C:/ and copy or clone the project in this folder.
Remove all builder folders and configure the project again.
That solved it for me.

Related

How to properly delete projects in PlatformIO?

I use PlatformIO with Visual Studio Code on Windows 10.
Now whenever I:
create a Project with a name X
close Visual Studio Code
delete the Project folder X
open Visual Studio Code
create a new Project with the same name X
I get an empty project with a main.cpp file as expected, but the IDE shows an error for the line:
#include <Arduino.h>
The Error says: "Include Error recognised. Update your includePath." (Translated)
However, if I try to build, it compiles just fine. Even uploading and running works.
This include error appears not only with Arduino.h but with all includes, even if the file is in the exact same location. And it appears in other files than just main.cpp as well.
Can you tell me why this happens? How can I reuse the project names of deleted projects? Or If I should not delete projects like this (delete the project folder), how else would I delete a project?
I tried this with multiple project names and different boards, always with the same result.
Things I tried so far:
I found a Folder .cache in the PIO directory. But unfortunately renaming it (after step 3) did not help: after restarting PIO it recreated the folder as expected but the error message is still here.
In the same location there is a file homestate.json that among other things contains the path to recently opened projects. I removed those entries without luck.
I am just starting out with VSCoode and PlatformIO so i can't tell you why all of what you are seeing is happening is happening.
I use VSCode v1.63.0 on Windows 10.
If you want to delete the old project name, reuse it or not, you can bring up the Command Palette under the View menu (Shift-Control-P for me) and search for Workspace: Remove Folder from Workspace...., it will only be listed if you have projects in the workspace. A list of projects will be displayed, selected which one to delete and click on it. There will not be a confirmation prompt.

Xcode says "You don't have permission" when trying to run. Tried a lot of solutions from here [duplicate]

Whenever I try to run my app in Xcode 6 Beta 4 I am getting the error:
The file "MyApp.app" couldn't be opened because you don't have permission to view it.
This error appears no matter what simulator or device I target.
I have tried:
Deleting all Derived Data from Organizer in Xcode
Repairing permissions on my drive
Manually elevating the permissions of the built MyApp.app
Restarting my computer
Has anyone else run into this problem and found a solution?
I use Xcode6 GM. I encountered the same problem. What I did was to go to Build Settings -> Build Options. Then I changed the value of the "Compiler for C/C++/Objective-C" to Default Compiler.
Having the problem on DEVICE too (not just simulator)?
The other solutions only fixed it for me on simulator, not device.
For me this problem occurred (in Xcode 6) when I would try to change the main info.plist properties whilst trying to change my app name.
In info.plist I had changed Executable File name to something other than the default ${EXECUTABLE_NAME}...
I had mistaken this field for the field that changes the name of the app under the icon on the springboard.
In Xcode do the following
Window --> Organiser --> Projects --> The app with the issue --> delete button in Derived Data.
I then cleaned the project and voila
works
For me, a simple Product -> Clean worked great
I've fixed it by cleaning a build folder. Just went to 'Product' menu and Option+Click 'Clean'. After that a problem was resolved.
There was a problem with the Info.plist of the project. I created a new project with the same name in Xcode 6 beta 4 and then replaced the real project's Info.plist with the new one. The project then built and ran fine.
Look at the diff, it appears like the plist might have somehow gotten mixed up with a playground's plist. The bundle identifier was "com.apple.dt.playground.iOS-18300-13" and the executable and bundle names were "iOS" along with some other oddities.
This is the full diff in case anyone needs it for reference:
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
- <string>iOS</string>
+ <string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
- <string>com.apple.dt.playground.iOS-18300-13</string>
+ <string>com.myCompany.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
- <string>iOS</string>
+ <string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
- <string>AAPL</string>
+ <string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
- <key>CFBundleSupportedPlatforms</key>
- <array>
- <string>iPhoneSimulator</string>
- </array>
+ <key>CFBundleSignature</key>
+ <string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
- <key>DTPlatformName</key>
- <string>iphonesimulator</string>
- <key>DTSDKName</key>
- <string>iphonesimulator8.0</string>
- <key>LSBackgroundOnly</key>
- <true/>
<key>LSRequiresIPhoneOS</key>
<true/>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
</dict>
</plist>
I've had same this error in Xcode 8.2. The reason I found out for me, another Info.plist is added in my project while adding library (manually copy).
So that Xcode is getting confused for selecting correct Info.plist.
I just removed that Info.plist from the added library.
Then it is working fine without any permission alert.
Please check if you have changed Executable file => $(EXECUTABLE_NAME) to any other name. If you have changed this name then it shows this error. Please replace it with $(EXECUTABLE_NAME).
Product -> Clean (command shift K) fixed it for me
My goodness!! I spent hours to resolve this issue.
On XCode 7.3 I was having project with no issues.
Mistake I did
I just Added physical folders and moved my files into them, problem started.
I tried everything
Default compiler
Clean and build
Reset simulator and reboot simulator, Xcode, iPhone even mac
Updated Info.plist
Deleting Derived Data
Editing the permission on the folder of the project
Checking my architectures
nothing worked :(
How I resolved
I was about create new project and then I just deleted those physical
folders I added, clean build and YESS!!
It works!!
Try "cmd+shift+k" to clean the project and rebuild. At least it worked for me
Sometimes opening old project in new version Xcode will get this message.
Go to Issue navigator and follow the warning hint 'Upate to reconmmented settings'.
Boom, magic!
I had similar issue (xCode 6.2) for sample code downloaded. I tried to set Executable Name to Default in Info.plist but this didn't worked.
Instead change Compiler for C/C++/Objective-C to Default compiler (Apple LLVM 6.0) instead of Unsupported Compiler(com.apple.compilers.llvmgcc42) for project.
My Application was working fine on XCode 9.4, but when I opened my project in XCode 10 I was experiencing this issue. For me the issue was the build setting. I found the answer in this page https://forums.developer.apple.com/thread/112141.
In short go to File > Workspace Settingsā€¦ > Build System and change it to "Legacy Build System"
1) Go Firstly Build Options.
2) Then changed the value of the "Compiler for C/C++/Objective-C" to Default Compiler.
clean and working :-)
I found that changing my compiler to LLVM 6.0 in the Build Options was enough for me (xcode 6.1)
I got same error on my Xcode 6.1.1 for a project downloaded from gitHub which was committed 4 years ago.
For me, setting Architectures to the default value Standard architectures(armv7,arm64) and Compiler for C/C++/Objective-C to Default Compiler in Building Settings worked.
I had the same issue in my project. Later on found that third-party (fmdb for SQLite) file used in project contained Info.plist.
Simply deleting the Info.plist file worked for me!
I recently meet the same problem for running an old project (initially created in Xcode 4.x) in Xcode 6.0.1.
I fixed the problem by changing the Architectures in Building Settings to the default value, which is "Standard architectures(armv7,arm64)".
Hope this could help anyone who got similar problems :)
I've had this error with a number of my older projects that I am getting out of the cupboard to update. It seems that using Xcode 6 with older code seems to bring this about for some reason.
I have fixed this in all projects that I have done this with by:
Delete Derived Data
in Product: do a clean
go to Build Settings in the project Target and go to Build Options and change the value of the "Compiler for C/C++/Objective-C" to 'Default
Compiler'.
I tried all of the listed answers and none of them was useful. The problem was due to existence of an another plist file linked from a submodule via cocoapods. Luckily this was my own module, so I just deleted this plist from the submodule project and reinstalled pods.
solution
Later on I understood that the key of the problem was in the name of that second plist: simply info.plist. You may rename the file and relink it via a sources section of a submodule
That second plist file had a unique name, so Xcode was not supposed to become frustrated. Even my target settings pointed on a main plist, not on a info.plist. Looks like Xcode takes special consideraions about that name
The bug reproduced in Xcode 6.4 and Xcode 7.0
Well in my case, I just rename the Bundle Name and Executable file values in info.plist same as project name. It worked for me.
What I did is here:
I deleted VALIDARCHS from Project
I deleted VALIDARCHS from Target
Build Active Architecture Only = YES (for Debug) Architectures
Standard Architectures $(ARCHS_STANDARD)
Also, File -> Project/Workspace Settings == New Build System
Xcode Version 12.0 (12A7209)
I had this similar problem. Somehow my value for the key Executable File got mixed up. Just change it back to ${EXECUTABLE_NAME} (Under your project > Info). Worked for me!
If you google the text of this error message you will find maybe 20 threads across StackOverflow, Apple dev forums, Reddit, etc. about Xcode failing to be able to run a compiled executable with this error message.
In these threads you will find many people offering various suggestions about how to fix the problem: changing product name to match project name, changing build phase options, something with info.plist, changing compilers to or from Clang, etc. Presumably the suggestions are offered in good faith because they solved the problem for someone, but the answers are so varied that it is clear that the error message is generic and this is an important point if you are receiving it: this error seems to mean that something is wrong with the binary. Ignore its actual text: it may have nothing to do with permissions.
There is no general solution to this error. The error message is totally generic; assume it means "bad binary file". The solution if you are receiving it depends on what you are trying to do, what has changed, why you are seeing this error all of a sudden. Google the specifics of your situation rather than this error message.
In my case, and I have a feeling this is a common case, what I was trying to do was build an old iOS project, nine years old I think, on modern Xcode. The solution was to switch to the legacy build system which led to a compilation error because in the old project there were not modern architecture targets, which could be fixed by manually adding them.
In my case main.m containing the main(...) function was not contained in the list of "Compile Sources" in "Build Phases". To check if this is the case, enter into Build Phases and look, if your main.m appears in the "Compile Sources" list.
Don't know if the problem is related but maybe it can be a solution for anyone pulling the hairs like me.
In my case, I have a project with a lot of targets. Each target is a customisation of that base project which is a Cocoa Touch Static Library and the targets, Applications. Even if the main file is added into the library compilation, but not in each target, that error message appears. So what I did? Manually added the main file to each target in the Compile Sources section and bingo, all fine.
For me the error was in the .plist file at the key CFBundleExecutable.
I had renamed the executable removing a space that was between two words. (Eg: from "Wild Racer" to "WildRacer"). Took 1 day to spot it!!
Xcode is soooo unhelpful in the debugging!
What solved it for me was setting Build Active Architecture Only from No to Yes.
with X-code 6.3.2
[Build Settings] Options.
[All]-[Build Options]-[Compiler for C/C++/Objective-C]-[Default compiler (Apple LLVM 6.1)]
Then rebuild the project, and it runs ok.

QIODevice::read: device not open

Im trying to read from a file and put into to the text edit and it keeps saying QIODevice::read:device not open. The .txt file is in the same location as my .qrc and .cpp file. I was following a step by step guide from online. From my understanding, they changed something when they went from Q4 to Q5. Does anyone have any hint on how I can fix this. thanks
//My findstuff.h
#ifndef FINDSTUFF_H
#define FINDSTUFF_H
#include <QWidget>
namespace Ui {class FindStuff;}
class FindStuff : public QWidget{
Q_OBJECT
public:
explicit FindStuff(QWidget *parent = 0);
~FindStuff();
private slots:
void on_goButton_clicked();
private:
Ui::FindStuff *ui;
void getTextFile();
};
If you're reading from a .qrc resource file you have to run qmake ("Build->Run qmake" in Qt Creator) before it will be available.
You're not passing the absolute path of the file to QFile::open(), and you're not checking the result of opening the file. In your case, it's a failure and open() returns false, but you're ignoring it, instead of fixing the problem (the wrong path) that caused it.
This has zilch to do with Qt 4 -> Qt 5 upgrade, and everything to do with you assuming the wrong thing about the current directory your application happens to find itself with. Generally speaking, the current directory (or working directory) is arbitrary, and platform- and circumstance-specific, and wholly out of your control. Unless the user gives you a filename that's implicitly referenced to the current working directory (e.g. as a relative path given a commandline argument), you must use absolute file paths or things simply won't work.
It can be related to the version of Qt, since Qt5 sometimes doesn't work with MSVC2010.
I have Qt 5.4 and my code gave the same error, when it was working with MSVC2010 OpenGL as a compiler. I manually added MinGW 32bit to use it as compiler and it worked.
P.S. I have not installed MSVC2013 for Qt 5.4., and it works sometimes with MSVC2010 OpenGL without error, but not in this case.
this is mostly the case if you close a file which is not opened - so just remove the close statement for example:
file->close();
just remove it ;)
I had this problem and it turned out Qt Creator hadn't actually added the .qrc file to my project. I'm using Qt Creator 4.1.0 on a Mac and the projects view doesn't always get populated after creating a new project, first requiring a restart of Creator. My version of this problem may relate to that.
It does not have anything to do with Qt version.
Even though your .txt file is in the same directory as your .cpp file, you still need to add the directory. I had the same problem and that simple solution worked well.
Arman Arefi

Trouble getting a Qt Reference Document program to work(Minehunt)... its just blank when run... no errors though?

http://docs.huihoo.com/qt/4.7/demos-declarative-minehunt.html
When I build and run... I just get a blank white rectangle... game is MineHunt.
The source code is in the URL. I created files and copied and pasted into Qt Creator 4.7.
Running in Linux.
No need to downvote. Deploying qml apps does not seem to be easy for beginners. jdl, I don't know if I can help you. Currently I am only on Linux. But what I did:
I copied the whole folder minehunt in my destination folder (/tmp/mine). When I ran qmake I got:
WARNING: Include file
/tmp/mine/helper/qmlapplicationviewer/qmlapplicationviewer.pri not
found
So I also copied the examples/declarative/helper folder into /tmp/mine.
Looked like this:
/tmp
/mine
/minehunt
/helper
Then I changed into minhunt, did 'qmake' and 'make'. A few seconds later I had a working minehunt binary in /tmp/mine/minehunt/.
I'll try tomorrow the Windows build.
Edit: Ok, tried now under Windows 7. Qt4.
QtCreator opened.
Project ...qt\demos\declarative\minehunt\minehunt.pro
loaded. Normally in release mode compiled. No problem. A file minehunt.exe was created in ....qt\demos\declarative\minehunt\release. Started: White screen. Exactly as you described it. In ...qt\demos\declarative\minehunt I found a folder 'qml'. I moved this folder and the minehunt.exe into another folder (myMineFolder). Simulating a simple deployment this way. Clicked on minehunt.exe -> worked like a charm.
So my folder layout:
myMineFolder
qml
minehunt.exe
But of course, I have set my PATH variable correctly to my Qt installation.

ui and cpp files are out of sync

Everything was fine until I decided to add another combobox (which I did not rename and is indeed called comboBox) into my .ui when I realized that ui->comboBox was not recognized. All my other widgets etc that I added awhile ago still work though. When I debug I get http://i.stack.imgur.com/xVs8X.png but i know for a fact that I created it. Usually bugs like these I could just close my Qt and start it up again and all would be well but not this time. Does anyone know how to possibly fix this issue? I'm using Qt5.1.0.
I noticed this problem after I built Qt statically. Could that be the issue?
Example:
detail.ui
trying to access the button in detail.cpp
As you can see, i can still access all of the previous widgets etc before I made Qt Statically. But now, when I make a new pushbutton, cpp file does not recognize this.
I had to run Qt5.1.0 for Desktop (MinGW4.8 32bit) prompt. cd C:\path\to\project.pro and then type mingw32-make clean
In my case there was a copy of the auto generated "ui_xyz" file in my working directory(source files) so the compiler wasn't referring to new one in the build directory.