I have a Visual C++ 2003 project which depends on a 3rd party static library. My visual c++ project also compiles to a static library. I have referenced the 3rd party library from my project by editing the project properties, adding the 3rd party library's directory to the Additional Library Directories (e.g. ./LibDir) and the library's name to the Additional Dependencies (e.g. 3rdParty.lib).
On my machine this works as I expected, adding this to the linker command line:
/LIBPATH:"LibDir" 3rdParty.lib
On my colleague's machine it adds this to the linker command line:
/LIBPATH:"LibDir" 3rdParty.lib "LibDir\3rdParty.lib"
This causes the 3rd party library to be linked twice, resulting in lots of errors and warnings.
This problem isn't specific to this library - it seems that whichever 3rd party library we try to include in this way on my colleague's machine ends up being added to the command line twice.
What is causing the difference in behaviour between his machine and mine?
UPDATE:
I've now tested this on a third machine, which demonstrated the same behaviour as my colleague's machine, i.e. referencing an additional dependency causes it to be added twice to the linker command line (this difference happens when I open the exact same project files on each machine).
The only difference I can think of between my machine and the other two, is that I installed VC++ 2003 on my machine a couple of years ago and on the other two machines this week.
Also, it seems that this only happens if my project is compiled to a library - if it is compiled to an exe the 3rd party library only gets added to the linker command line once.
Any ideas...?
Check is there any unnecessary inheritance of dependencies in Your friends project in Additional directories.
Try to exclude Your 3rdParty.lib,
check is there any $(ProjDir) or any simmilar additional, differences in the properties.
Could You post Your command line from compiler/linker (this could be found in properites).
I had the same problem and moved the included libraries to a directory structure that didn't have any spaces in it. It worked fine then.
Related
I must have read over a dozen posts on possible techniques to link a local library into my Swift Package. Specifically, my package depends on libturbojpeg.a, which most users won't have installed anywhere. Even if they did install it (there is a DMG), I'd have to go through hoops to make sure I was linking in the correct version. I finally found a post in the Swift Forums that basically says you can't do it now.
It appears that the only way to link it now is using .linkerSettings(LinkerSetting.unsafeFlags(..., but if you use that your package can't be managed by Xcode (see above link, and I even tried it and verified it cannot be used).
Is there some kind of workaround that allows me to distribute my Swift Package with the library?
In my Package, I created a directory "Libraries" and added my library there.
I discovered that Xcode 11 places included Swift Packages in a specific location in the Derived Folders directory. This means that it is possible to tell Xcode where to find it during the link phase.
My Package has these instructions in it for users:
1) Add the Package using Xcode->File->Packages with the URL of https://github.com/dhoerl/
2) Open the app's Project Build Phases, and from the Package shown in the left file pane, drag the Libraries/.a file into the link phase. It will appear just above the that should already be there
3) In Application Build settings, under library search paths, add:
"$(BUILD_DIR)/../../SourcePackages/checkouts//Libraries"
Build and run! Voíla - works like a charm!
Note: obviously this is somewhat fragile, Xcode 12 could change how packages are managed, but its possible by then that the Swift Package Manager will support linking of local libraries (its mentioned in the above link.)
I've been playing around with the Starter Edition of Xamarin Studio to determine if it will meet my needs. I understand (so I thought) the limitations of this edition; 32K compiled IL limit, no native libraries, etc. Now, I understand native libraries to be C/C++ libraries, or even native Java libraries. This does not seem to be the case.
I have a solution in Xamarin Studio with 2 projects. One is an Android Class Library, the other is an Android Application. When I reference the class library from the application project and build, I get the following error.
Your app references native libraries. This functionality requires Indie Edition or higher.
I beg to differ! Every .cs file in the referenced Android class library project is simple .NET code. What am I missing? I can successfully run the Tasky Android_Starter solution without issue, and it is made up of 2 projects like mine.
I had to delete the Resources folder and manually edit the Android class library project file in order to get this working. I looked at the Tasky sample's project file as a reference.
After deleting the auto-included Resources folder from the project, edit the .csproj file in a text editor to remove the following XML elements:
Project\ProjectGroup\AndroidResgenFile
Project\ProjectGroup\AndroidResgenClass
With those things taken care of, I no longer get the error. I'm guessing, Xamarin Studio thought I was referencing another Android application instead of a class library. Not sure why the default project template includes things to break such a flow, but perhaps I'm not "doing" right" either. Go figure.
Deleting the Resources folder and manually editing the csproj file didn't work for me. I had to create a new C# Library project instead of creating an Android Library Project and import my .cs files into that. After that it compiled and ran fine.
I have a C library whose code resides in say /repos1/clib. I build that from the command line using the latest iOS sdk to create clib.a (including a debug build for the simulator) which I copy to an iOS project say in /repos2/proj.
I have been using this setup for several years. The old C library very occasionally might require some debugging and I was pleased by the fact that Xcode simply stepped into the library code that was outside the project (inside repos1) without having to do any setup - it just worked.
But this was up until a few Xcode versions ago. I am not sure exactly when it changed - perhaps when they moved from gcc to llvm? - since I very seldom needed to debug the C code, but for a while now I only get dissasembly when I try to debug the C library from the iOS project (including at least references to the C file name & line number). For the few times I need to debug it is very inconvenient (I create a temp project that includes the C code).
So, any idea why it worked before and doesn't now? Where should I look? Could it be the way I build the C library, maybe there was a flag in gcc I was using that does not have an equivalent in llvm (I can find and post the old build command I was using if it is relevant)? Is the issue in Xcode and there is a way to tell it where to look for the sources?
Thanks!
Edit: To make it clear, I can add the C library either as the source or as a subproject in Xcode, however for reasons that are out of scope this is not helpful for this specific project. So, can it work like it used to with older Xcode versions? If not, it would still be interesting to know why not.
The recommended approach is to create a library project in Xcode, one for iOS (there is a template for it), then when you get that to build add that project to your app, make sure the lib is a dependency and gets linked. There are many tutorials on the web how to do this.
Then as iOS evolves and new architectures (armv7s) arrive you simply update both projects.
I was struggling with the same issue.
I tried resetting in library/application project all options related to symbol stripping and copy application project to same truecrypt drive as library project but it didn't help.
In my case it appeared it was an app project issue. Same library could be debugged in another app project with source code so that was a clue.
I had more than one version of the same library in app project and set only target membership to choose which should be used. Not sure if that could affect my app project somehow.
Nevertheless after deleting all libraries and copying them to app project again I was able to debug libraries with access to source code.
I am currently building a library which should be used internally in a few iOS projects but should also be distributed to customers accessing our services with the library. The Library itself consists purely of C++ code and I am basically able to create Apps with it on iOS which work fine. My problem is creating a single, easily distributable file that can be given out to customers which can easily install them, use the provided headers and don't need to have the headaches that I am currently facing when it comes to linking.
Our code depends on two other projects, namely boost and websocketpp. For boost there is the script on github which I took to generate a framework. For websocketpp, I imported it into XCode and used the scripts from this github project to build a framework. I added both frameworks to my (potential) framework as dependencies and used the same script to build one.
I have an app using my library as a sub-project working fine. Even including the framework into the project and running it on a device works fine. So far so good.
However, trying to create an archive of the App project lead to several questions and headaches.
My library did not seem to contain the code for all architectures. So I tried to archive the Framework projects, which after small modifications in the build scripts to use different locations to search for headers worked fine.
It does not seem to contain all binary code or references to local files (i.e. my specific location of boost). I gathered that from Linker errors that I still get that tell me that some boost calls could not be satisfied.
The second issue made me think that I am must be doing something fundamentally wrong and my intuition tells me that it can't be that difficult and "hackish" to create frameworks or libraries for others for iOS development.
As you probably have found out by now, I am not very experienced when it comes to iOS and I am wondering if I am missing something fundamentally. So, I am sure that this question is rather broad, so some more concrete questsions:
Is there a(nother) way to generate some kind of distributable (preferably a framework) which contains: my public headers, my binary code compiled for all platforms supported for iOS development, the binary code of dependencies?
Is the only way to do that by adding some handwritten scripts to the build process?
I have the feeling that the information I found is quite outdated since it's older than a year and mostly refers to Xcode 4.2 or 4.3 -- so has there anything changed in this regard recently?
For example one error I get is:
File is universal (2 slices) but does not contain a(n) armv7s slice: <file>
The <file> slice is the path to the file in the framework in the Products folder of a different XCode workspace (the library was build in a different workspace then the app). I dropped the framework folder into the project for this test from a completely different location.
What is going on here?
Why does it keep referencing to some internal XCode directory?
How do I properly export it?
Since I guess my setup is probably skrewed up and weird from all the different things I tried up to now: How does this setup look like in a ideal situation?
Yes, there are some questions regarding this on SO already, however, either I don't see or don't understand in those replies:
...how to handle depencies of my code to other third-party code properly.
...how to generate a distributable file.
Have you checked your project build phase under Compile Sources and Copy Files to see if you are including your framework source files in your build?
You may also try the C/C++ Library template under OSX -> Framework & Library.
Finally, there's also kstenerud’s iOS Universal Framework, which I found very useful. I wrote a few articles in my blog on using it.
here I have just started my fyp and ints gona be in opencv.
I needed to vectorize the image and in order to do that I chose to use cvblobslib.
I downloaded it and it was build successfully but when I use it in my project there's a link error saying that "could not open cvblobslib.obj"
the exact string is pasted below
fatal error LNK1104: cannot open file 'E:\Faizan\myWork\moCap\blobslib\Debug\cvblobslib.obj'
of the solutions which I found on net and tried on my project are to remove any spaces in path, build in release mode rather than in debug mode, but problem was not solved.
the thing is that the stated file does not get built with other files when cvblobslib is built, i.e it is not there in the stated folder.
any body please give a solution
What exactly are you trying to use the cvblobslib for? I also tried using this with no luck. I found that openCV has a lot of the same capabilities. For example, you can use cvCountours to detect "blobs" and filter them by area.
(ps. i tried leaving this as a comment. do you need certain amount of rep to do that?)
cvBlobsLib has been developed using Microsoft Visual C++ (6.0) and can also be used in .NET. A Linux version could be downloaded here.
cvBlobsLib is distributed in a static library (.lib). To use it, it is requred that you build the .lib file and later use that lib file in the desired project. To build the .lib file, simply open the MSVC++ project and build it (debug or release version).
To build the project where the library is to be used follow this steps (MSVC++ 6.0):
In Project/Settings/C++/Preprocessor/Additional Include directories add the directory where the blob library is stored
In Project/Settings/Link/Input/Additional library path add the directory where the blob library is stored and in Object/Library modules add the cvblobslib.lib file
Include the file BlobResult.h where you want to use blob variables.
In Project/Settings/C++/Precompiled Headers select Not use precompiled headers
NOTE: Verify that in the project where the cvblobslib.lib is used, the MFC Runtime Libraries are not mixed:
Check in Project->Settings->C/C++->Code Generation->Use run-time library of your project and set it to
Debug Multithreaded DLL (debug version) or to Multithreaded DLL ( release version ).
Check in "Project->Settings->General" how it uses the MFC. It should be "Use MFC in a shared DLL".
NOTE: The library can be compiled and used in .NET using this steps, but the menu options may differ a little
NOTE 2: In the .NET version, the character sets must be equal in the .lib and in the project. [OpenCV yahoo group: Msg 35500]
NOTE 3: cvBlobsLib might give errors when building with OpenCV v2.2 onwards. Try commenting out this line in file BlobLibraryConfiguration.h:
#define _SHOW_ERRORS
NOTE 4: If you are using the new cv::Mat for your images instead of the old IplImage, you can easily convert between them, such as by following the OpenCV C++ Cheatsheet.