I'm using C++Builder. I want to include a header file that is located in a separate folder from my project.
I tried to add the folder to the search path, and include the file in my project:
#include "GXWARE32\Include\gxutils.h"
but when I compile I have some errors in the file included
So, I tried to add all subfolders to the search path, and it works with a small folder but not with a big one.
According to the error log, maybe you missed some header file that gxutils.h relies on.
Without code, we can only guess... some libs need a specific #include order... some libs have hard-coded relative paths and by moving them you broke that... Some libs also need configuration macros defined before #include.
From the errors, you have #include'd some file more than once (and it's not protected by a header guard, like #pragma once or #ifndef file_id #define file_id ... #endif macros) and you are missing a previous #include for some datatype used.
Open the gxutils.h file and look around line 143 for the missing datatype. In the IDE, during compilation the cursor usually stops on the stuff directly. Then just search the files in your lib for the datatype, so you know what file to #include before...
All of these might happen sometimes if you include the wrong file... some libs need to include cpp instead of h...
Adding search paths will not do anything as the compiler is not complaining about files not found...
I have a Xcode template file like so:
#import "___FILEBASENAME___.h"
#implementation ___FILEBASENAMEASIDENTIFIER___
#end
This will create an example file like so:
#import "ExampleFile.h"
#implementation ExampleFile
#end
However due to some complexity in our build system, I need to import files by their file path.
For example, if I was creating ExampleFile.m inside of Path/To/ folder. Then my desired output would be:
// Desired template output
#import "Path/To/ExampleFile.h"
I tried looking through some Apple example templates, but didn't seem to find a way to make it work.
I also stumpled upon ___DIRECTORY___ referenced here, but it doesn't seem to work for me when I attempted to use it.
Does anyone know if there is a way to accomplish this?
Try enabling "Use custom working directory" option, it will let you choose the base directory.
How to enable this is answered in the following question.
Xcode: How to set current working directory to a relative path for an executable?
Hope this helps
I have created a manual bridging-header using these these instructions. However, my project name has a space in it. I get the following error when compiling:
Bridging header '/Word-Word/Word-Word-Bridging-Header.h' does not exist
Here is what I have put under the bridging-header section in the project's build settings:
/Word-Word/Word-Word-Bridging-Header.h
How can I get the correct file path? Thanks!
I had to leave the space in there rather than adding a dash between the 2 letters.
Is that truly the path? I would tend to think not, since it implies it is at the root directory.
Assuming you mean the Objective-C Bridging Header setting from Build Settings ... that path is relative to the file your .xcodeproj is located. So, for example if your structure looks like
Word-Word.xcodeproj
Word-Word/ (note this is a directory)
Word-Word/Word-Word-Bridging-Header.h
You would need the Objective-C Bridging Header to be Word-Word/Word-Word-Bridging-Header.h.
If your bridging header is in the same directory as your .xcodeproj, then you would need to set it to be: Word-Word-Bridging-Header.h
Since only you right now know your directory structure, you will need to determine the proper relative path to use.
I am thinking about that it would be a great idea for examining that the class type. In example I would like to do the following in my application prefix.pch file.
#if isViewController
#import "DeviceCompatibility.h"
#import "UIViewController+Utilities.h"
#endif
How could I do this.
Thanks for the ideas and your time
This won't work. The point of a pch file is that it is a "Pre Compiled Header" file. It's compiled once and then that is used in every other file.
What you are asking for would require that it not be pre-compiled since it would need to be evaluated for each file. What you want is what regular, non-pch files are for.
I got this error when I press build+debug:
ld: duplicate symbol .objc_class_name_BlogTableItemCell in /Users/fabian/Development/Workspaces/iphone_experiments/xcode_build_output/MausLog.build/Debug-iphonesimulator/MausLog.build/Objects-normal/i386/BlogTableItemCell-3733583914888A7B.o and /Users/fabian/Development/Workspaces/iphone_experiments/xcode_build_output/MausLog.build/Debug-iphonesimulator/MausLog.build/Objects-normal/i386/BlogTableItemCell-3733583914888A7B.o
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
You could also get this error if you mistakenly let Xcode's auto-complete for #import statements specify the '.m" file for the 'duplicate' class instead of the '.h'.
It seems that you are compiling the same BlogTableItemCell class two times in different places of your code. This may happen in the following cases.
You have put the same class
implementation into two different
files;
You actually have just one
implementation of this class, however
you are also linking in your project a framework
or library containing a class whose
name is exactly the same of yours.
Try finding in the whole project your class and make sure only one copy is available within your project.
For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation )
I had a similar problem due to poor defining of consts.
I had defined a const in my header:
int const kCropLocationTop = 1;
This was presumably imported multiple times. To fix i changed the header def as follows:
extern int const kCropLocationTop;
and moved the assigning of the const to the .m file:
int const kCropLocationTop = 1;
Hope that helps anyone who's as ignorant of simple objective c concepts as I am!
iPhone: Duplicate Symbol Error? by user576924
answered it correctly for me. However to find the offending gremlin this ZSH snippet.
grep "import.*\.m" **/*.[hm]
Will immediately tell you where your error is.
By mistake the source file was included twice in the Project -> Build Phase -> Compile Sources. Removing one of them solved the problem.
The most common reason for this error is importing an xyz.m file instead of the xyz.h file.
Check if your imports contain something like
#import "----.m"
Just to add; Using Xcode to generate subclassed managed objects (Core Data) can sometimes duplicate the generated files. For me the fix was to delete the generated files and re-generate them.
I just ran into this problem myself. For the list, here's another possibility:
Duplicated linking line in the project file.
I caused this merging conflicts on a SVN update, when I accidentally duplicated a line.
It happened to me, too. In my case, one (just one) of my core data automatically generated classes was inserted twice. I spotted the duplication by looking at Build Phases...Compile Sources. Simply deleting one of the occurrences solved the problem.
Adding another possible cause to the list... you may have mistakingly created multiple constants in the implementation file, but outside of the implementation, with the same name.
In HeaderFileOne.m
NSString * const kCoolConstant = #"cool";
In HeaderFileTwo.m
NSString * const kCoolConstant = #"cool";
So changing one of those constant names would fix the compile error.
This may help someone
I got this error because I duplicate a ViewController and then renamed it. So when I compile I got this error. The reason was in both of the view controllers there was a "float" variable with same name i.e "float padding=10.0" which I had defined on class level.
Renaming the name of the above mentioned variable in One of the view controllers solved my problem.
I also faced to this problem. My solution was rename one of global variable, which has the same name as one in other class. Hope this helps
The same thing happened to me while I was playing with localizable xib files, accidentally I have created two implementation files and appereantly that caused the problem in my case. After deleting / recreating the implementation file without doing the same mistake, the error was fixed.
One of our developers left the "libSoomla*" project files in there twice. I removed the duplicate soomla files, re-built, and that fixed it!
Hope it helps.
In may case, I followed some instructions to build a newer version of Subversion which directed me to create this symbolic link:
ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
Now I'm really a Windows guy so it wasn't immediately obvious to me - but removing the link fixed it for me (after restarting XCode):
rm /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
Phew.
(The actual error I got was the one described here:
build error duplicate symbols arclite.o)
Make sure that you didn't import .m File . For me this happen I added #import "SchoolCommuterHome.m" instead of #import "SchoolCommuterHome.h"