I have this folders structure:
~/css/file1.less
~/css/folder/file2.less
What I want to do is importing file1.less inside file2.less, so in my file2.less I have this code:
#import "../file1.less";
This do not work, and the compiler crash when I build the project.
I execute the compiler in Visual Studio 2010.
How can I import a less file placed in a parent folder?
You must prepend ./ to your path. For example :
#import "./../style.less"; /* Correct */
#import "../style.less"; /* Wrong */
This seems to be a bug in LESS.
Comments in the bug report suggests that it is fixed in the main branch, so if you get the latest version from git, maybe it will work.
See https://github.com/cloudhead/less.js/issues/177 and this post on StackOverflow: Node.js + Express.js. How to RENDER less css?
I just tested importing a file which is one level up the way you did it and it works for me.. What's the compiler's error on crash? The error may help you.
On a sidenote, you should probably keep your .less files structured differently.
Try this:
#import "~/root_css_folder/parentfolder/file1.less";
Related
I'm currently working with singularity.gs v1.7.0 and I noticed that the helper files _box-sizing.scss, and _clearfix.scss, are not included into the _helpers.scss file. I did had the same experience with singularity.gs v1.6.2.
Here is how I'm including singularity.gs into my SASS code and also how I'm going around this issue:
#import "_singularitygs.scss";
// for some reason the content bellow wasn't called from inside singularity
#import "singularitygs/helpers/_box-sizing.scss";
#import "singularitygs/helpers/_clearfix.scss";
// end of missing libraries
Can somebody confirm if this is a bug or not, and what would be the preferable procedure to including these two files?
Unfortunately I wasn't able to find a clear answer on the documentation.
Thank you
So I have a structure like below. (Similar to bigger project I'm really working on)
tryWithNewLib\testProject\testProject\testProject.vcxprog
tryWithNewLib\testProject\testProject.sln
I have this open source library I want to use.
tryWithNewLib\XERCESCPKG-31-VC100\include\xercesc\util
Additional Include Directories:
D:\tryWithNewLib\XERCESCPKG-31-VC100\include;%(AdditionalIncludeDirectories)
I am expecting this to work:
#include <xercesc/util/PlatformUtils.hpp>
Any ideas on what I am doing wrong?
I believe the issue may have been that I was updating Additional include Directories for the wrong configuration. (I've changed a million things so I'm not sure this is really the fix).
I have the following project setup:
1) A main iOS project ('super project')... nothing special here, the project was built on top of one of the default iOS templates from Xcode.
2) A second project ('subproject'), which was created on top of the Static Library template. I added this project to the super project, and created references to it from the superproject in the 'Target Dependencies' and 'Link Binary with Libraries' build phases.
Inside the subproject, I have a C function declaration which looks like this:
ABAddressBookRef myABAddressBookCreateWithOptions(CFDictionaryRef options, CFErrorRef * error);
It's meant as a replacement/proxy of the similarily named function from the AddressBook framework and uses a type (ABAddressBookRef) from that framework. The declaration is stored in a header file, and the implementation exists in the corresponding .m file. To make this type available, I added the framework header to the .pch file of my subproject:
#ifdef __OBJC__
#import <AddressBook/AddressBook.h>
#import <Foundation/Foundation.h>
#endif
The following problem occurs:
If I build the superproject (release or debug config), the build fails with this error message:
.../ManagedCFunctions.h:24:1: Unknown type name 'ABAddressBookRef'
Things I've done to fix the issue, or at least get an idea of what's going on:
Building the subproject separately works (but a subsequent superproject build fails regardless)
Uncommenting the declaration gets rid of the error, but naturally raises an "Implicit Declaration of Function" warning at the calling location
Adding the import to the superproject's .pch file does not help
Adding the import to the header file of the function directly works, but is not an option in my scenario (parts of the code are autogenerated, and it would be hard to find out which file needs which frameworks)
I suspect that maybe the header file is not processed in Objective-C, but rather C mode, so the imports are ignored due to the #ifdef __OBJC__ macro around the import, but removing it hasn't helped either. I also tried to add #import <Foundation/Foundation.h> to the function's header file to 'suggest' Objective-C mode, and it actually enabled correct syntax highlighting in the file, but hasn't helped for building.
Any suggestions as to why the symbol is found in the .m, but not in the .h file? Or any workaround that does not require adding the import to a specific header file, but globally?
Today I found a isuue after I in project -> Info -> Configurations add a configuration file, then I run my project, it goes wrong in my pch file.
It shows that xxx.h not found, I search a lot of solutions, but I can not get the right answer. So I remember that step.
I deleted the configuration file, and my project become normal.
I hope this will be helpful for this kind issue.
when I create an xCode project with the 'Command Line Tool' c++ stdc++ template, i am able to include and compile opencv headers and run some code.
But i want to use OpenCV in a 'Cocoa Application' context. When created with that template, i got compile errors when I include the OpenCV headers in main.mm. (I already changed main.m to main.mm, the '//NSApplicationMain(argc, (const char **) argv);' is commented out)
One of those errors is: "Statement-expressions are allowed only inside functions"
I suppose its some kind of compiler version error, but when i compare the project build settings i cant find differences.
Do you have any ideas/expertise?
I ran into the same problem, I spent 2 days doing serious system tracing and as expected, the solution was so simple that an 8-year-old could have found it more quickly than I did.
Ready for this?
In the .mm file where you want to use OpenCV, you need to do your #include "opencv2/opencv.hpp" BEFORE any other includes. That's it! Just move it up a line and watch your problem magically disappear faster than that rug that really tied the room together.
This is for OpenCV 2.2 by the way, hence the new include file. Also if your XCode project uses a prefix header file (look in "Other Sources" for a "YourProjectName_Prefix.pch" file), then you'll need to put your #include "opencv2/opencv.hpp" there instead of in any other file.
Ian Charnas's Answer is correct, but there is one modification I would make.
This article has a more specific solution, and an explanation of why you need to do this.
http://aptogo.co.uk/2011/09/opencv-framework-for-ios/
// Add this new section BEFORE the #import statements for UIKit and Foundation
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
Even if you rename your "main.m" to "main.mm" and moving the "#include opencv2/opencv.hpp" to the top (in the main file), the preprocessor will insert cocoa.h first because of the precompiled header files nemed something like "_Prefix.pch". To avoid such problems
- delete the #import statement or
- insert an #import statement above the cocoa.h import statement
Try adding: -lstdc++ to the "Other linker flags" in the build settings for your Cocoa app.
A cocoa application made by the Xcode templates won't link include the c++ library in it's settings by default.
add this to your .pch file
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
dont forget to convert all of your .m files into .mm files
You'll probably find it easier to use OpenCV's C API rather than the C++ API. You can call C APIs directly from Objective C of course, so this makes life a lot easier. You just lose some of C++'s syntactic sugar, like default parameter values.
I have duplicate symbol _main.
The problem is it says "Duplicate symbol _main in /Users/.../i386/main-B9843B6026D6EFA4.o and /Users/.../i386/main-B9843B6026D6EFA4.o", the XXX and XXX are actually the same .o file. I don't know why it thinks it's duplicate symbol when it's the same .o?!
Any help appreciated, thanks.
Ah..I figure out it's that I have multiple entries under Targets/Compiled Sources ( in newer XCode it's under Build Phases/Compile Sources ). I removed them and the problem is solved. The multiple entry thing probably has to do with Git merge.
It appeared that in my case I was importing a .m file instead of its .h counterpart.
Solved by editing
#import "Tools.m"
into
#import "Tools.h"
I also had this problem and it was caused by code I imported from another project.
I did a grep for "int main" in my project directory:
grep -nr "int main" .
and found
./main.m:13:int main(int argc, char *argv[])
./IMPORTED_DIR/main.m:13:int main(int argc, char *argv[])
the IMPORTED_DIR contained the extra main.m that was causing the error for me
I removed that file from the Project -> Targets -> Build phases -> Compile sources list and then it compiled
I was facing the same issue with using two third party framework. (AppLovin and Flurry)
And I came to know that by removing "all_load" from "Other Linker Flags" in build settings.
I had the same problem opening a project, that was created with Xcode 4.0.2, with Xcode 4.1. I simply solved by clicking on "Modernize Project" (Editor/Modernize Project). This procedure automatically removed all duplicates.
If still have a problem, try to search like this: "int main(", and remove those files except main.m
Just got this problem myself, but after reading huggie's solution which did lead me on the right track, I was left a bit confused.
So current solution in Xcode:
Choose project, target -> build phases and click validate settings
Then Xcode will auto fix its own mistake. It is always nice when the tools tries to stop your progress ;)
In my case, I declared an NSString in my constants file (imported by many classes) but forgot to define it as static!!
e.g. NSString* PARAMS = #"paramA";
should be: static NSString* PARAMS = #"paramA";
Reading the full error message allowed me to figure this out: "Duplicate symbol PARAMS". Don't be afraid and try to understand error messages! Sometimes they might even tell you exactly what you did wrong.
In my case, I had imported another project, in order to utilize a library contained within. It resulted my project having two main.m files.
This was even more confusing, since the error didn't show up until several builds later.
You can get this for method names too!
I got duplicate symbol _runOnMainQueueWithoutDeadlocking after adding DBCamera via CocoaPods and it was because both my category on NSObject (NSObject+Tools.h) and the GPUImage dependency file GPUImageOutput.m both had a method called 'runOnMainQueueWithoutDeadlocking'.
I was fortunate enough to be able to remove my method from code because I wasn't actually using it anymore or anywhere.
It's probably what I deserve for putting a category on NSObject.