So my project today has been to create a C++ class that consolidates a lot of our commonly used crypto tasks. Got lots of things working but ran into a bit of a snag here. For reference, I'm using XCode 3.2.5 on OS 10.6.5.
I'm attempting to utilize some of OpenSSL's CMS functions. OpenSSL's MAN Page for one of the functions I'm trying to use mentions it was included in version 0.9.8. That's the version XCode let me import without having to do anything out of the ordinary (Target -> General -> Add Linked Library). Yet with that added XCode tells me it can't find openssl/cms.h.
So thinking maybe there's some disparity between the OS X version 0.9.8 and the one on OpenSSLs page, I downloaded the source for 1.0.0c and built it. After it was built, I added libcrypto.a and libssl.a to my project as linked libraries and added "some/dirs/openssl-1.0.0c/include/**" as a header search path. Now it can find openssl/cms.h but I get a linking error on any CMS function I call.
Has anyone done this successfully? Any help would be appreciate.
Thanks!
So what I ended up doing was to create a new SDK and calling,
./Configure darwin64-x86_64-cc --prefix=/path/to/sdk/usr --openssldir=/System/Library/OpenSSL enable-cms shared
To update the version of OpenSSL included in that SDK. That's seemed to work.
Related
Im writing xml signing utility using C++ to run on Linux (only). And I need support of GOST, GOST2012.
I'm using xmlSecOpenSSLKeyDataGost2001Id, xmlSecOpenSSLKeyDataGostR3410_2012_256Id, xmlSecOpenSSLKeyDataGostR3410_2012_512Id in xmlSecKeyDataCreate() function.
Code compiles fine. But during link I'm getting error about undefined references to xmlSecOpenSSLKeyDataGost2001GetKlass,
xmlSecOpenSSLKeyDataGostR3410_2012_256GetKlass, xmlSecOpenSSLKeyDataGostR3410_2012_512GetKlass.
Should I add some specific library to add support of these methods?
Thanks.
I've got it.
All you need to do is to build xmlsec library with --enable-gost and --enable-gost2012 flags. Then you need to configure your project to use newly built libraries (or install them).
I'm working with a bit of a legacy cpp code base. This code base is reliant on Poco, more specifically Poco/MySQL.
When loading Poco via Cmake, it attempts to find the MySQL include and libs. I have the source code of MySQL in a folder nearby, and am attempting to link it in the CMake. While I was able to get the include directory linked correctly, it's still not finding mysqlclient(_r) and I have no idea why. I'm currently attempting in on Mac, but I'd like to make it cross platform as well.
FindMySQL.cmake:
find_library(MYSQL_LIB NAMES mysqlclient_r
PATHS
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/mysql/mysql/lib
/opt/mysql/mysql/lib/mysql
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
${CMAKE_CURRENT_SOURCE_DIR}/../../mysql/lib
${CMAKE_CURRENT_SOURCE_DIR}/../../mysql/libmysql)
message("${MYSQL_LIB}") # MYSQL_LIB-NOTFOUND
https://github.com/mysql/mysql-server
That's the MySQL source I'm attempting to build.
After a very long time I found the answer.
Changing it to include_library instead worked fine as it was an include only library.
To clarify the clarification:
I know how to create libraries in Xcode using either obj-c or swift. I know how to use these in projects. I know how to compile these projects so everything works. What I do not know is how to take open source C source code (hehe) and build/make/compile it into a library.
Just to clarify everything below:
I am looking for a way to use c libraries in a Swift application, this means using Xcode. The c libraries do no have to be build with/in Xcode, I am fine with using other tools.
I normally write all the code I use myself and unfortunately I only write Swift in Xcode. So I am a little behind on using frameworks/libraries.
Now I really want to explore Tesseract OCR and I am having trouble building the libraries needed. To me it is better to really understand how this works and be able to do this myself and not just look on Github and find pre-compiled sources.
The projects below both handle this differently. The iOS version uses precompiled Libraries. (.a file) The OSX version uses projects that contain the library files (not yet compiled).
An iOS compiled version
An OSX compiled version
libjpeg example of a library that can't be just dragged and dropped.
Using brew will only install it as a command line tool, not generate a lib.
install Tesseract with homebrew
The problem I have is that I know too little about these c libraries, and how to build them to even google this effectively.
My question:
How do you compile/build the c code into an .a file?
How do you create an xcode project that builds a framework based on
the c code? (optional)
What is the right vocabulary for all this?
I am not looking for a Tesseract specific answer. I want to learn how to do this myself.
about static libraries
This article doesn't mention how to actually add the c program and let xcode make it. The part about workspaces is interesting though.
Article on building c project in Xcode
This one is actually really relevant. However I can't find the executable in Tesseract for example. All options are greyed out when doing step 5.
This looks pretty : simple c++ procect
Why can't tesseract look like that? :)
If you want to build Tesseract, follow the instructions for a UNIX system:
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
You don't have to, in fact you shouldn't use xcode (which is simply a GUI/frontend) but stick with what each library tells you to use. In some cases it might be possible to build with xcode.
Projects that intend you to use xcode for their building, tend to include a xcode project file.
Apple's compiler is llvm/clang, so it may have some slight differences from Linux's GNU gcc/g++.
EDIT
You need to first install leptonica and automake:
brew install automake
brew install leptonica
Then run the building instructions.
As you will notice during make install the library is in
/usr/local/lib/libtesseract.a
And the headers are in:
/usr/local/include/tesseract
From there on, its a matter of using it in your project.
I tested this on OSX Yosemite 10.10.5 with brew and command line tools.
This is a big question. For the part, I had a recent encounter with Xcode.
How do you compile/build the c code into an .a file?
Click on Xcode project name Yourproj (the root node of the tree on the LHS)
Choose the target Yourtarget on the TARGETS section
Click Build Phases on the upper bar
scroll down to Linking section
change Mach-O Type to `Static Library
As per 'C' language requirement, AFAIK this can be changed on the fly:
From the last point above, scroll down to Apple LLVM - Language section
change C Language Dialect to your choice, say GNU99
If necessary choose Compile Sources As: 'C'
Scroll up to Packaging and edit Product Name to Yourtarget
Edit Executable Prefix to lib
Edit Executable Extension to .a
Now the output should become a file like libYourtarget.a
How do you create an xcode project that builds a framework based on the c code?
YMMV, based on what language you choose. I have not used Swift yet. Just add the libYourtarget.a as an Other framework of Yournewproj. The proper way of doing this is
Click on Xcode project name Yourproj (the root node of the tree on the LHS)
Click on Build Phases on the upper bar
Make sure a target is selected on the left
Now expand Link Binary with Libraries and click on the plus sign and then Add Other button
Browse to your libYourtarget.a file and click open.
This should work. If not, try to get rid of compiling errors as it is YMMV as already mentioned.
Hope this helps.
I am currently taking a few different online programming courses, one of which is the Programming Abstractions Stanford course. They have a set of default libraries that are utilized for the class.
You can download that package here:
http://see.stanford.edu/materials/icspacs106b/cs106libs_for_xcode.zip
I am needing assistance with figuring out how to get this package of libraries into Xcode so that I can utilize them with the programs I write. How can I go about doing that so when I create a new project I can create one that has these libraries ready to go, on top of the standard C++ libraries.
Thanks a bunch in advance!
Edit: I did install the .pkg file, but I do not where it installed. How do I utilize the installed library from within Xcode?
Bad luck. From this page:
How to install external library in X-Code 4
You need to install XCode 3.0 in order to use
CS106LibrariesForXcode.pkg library.
XCode 4 have a very different UI and functionality compared to XCode
3. So it would be unwise to study XCode 3 only. But if you're going to study C++ using those tutorials you'd probably want to install XCode 3
and use it.
Old answer [Not applicable]
If the package is a pkg file, you actually needs to install it. Double-click on it, follow the steps.
If you have a warning message,
CS106LibrariesForXcode.pkg” can’t be opened because it is from an
unidentified developer.
then right-click (or ctrl+click) and select open. The warning will then have an open option to allow you to open the package.
Once this is done, just write a new program, and include the headers you need.
I am new to the XCode environment so apologies if this sounds trivial.
I am trying to use a third party library using for OpenCV that helps me do some blob analysis, CCL etc. Hosted here
I have searched a lot but there doesn't seem to be much documentation on how to go about adding and using these new libraries. I am using XCode 4.5.2, OpenCV 2.4.2.
When I simply add all the header files to the project folder and #include them in the source code, it fails to compile. I have also tried adding the "Header Paths" but it doesn't help. What am I missing?
I have tried to follow the instructions (compiling it using the terminal but it doesn't compile too) I am not clear on how or when exactly to use CMAKE.
Any help will be appreciated. Thank you.
I would suggest you using CvBlob on google code which is different from the one on willowgarage, I have got recently confused with this so take a look at this question for alternative blob analysis libraries.
Moreover, CvBlob has also a good support community here. (Search on "[cvblobslib]" or on "[blob] [opencv]")
Try this: cvBlob: OSX installation
Once you get it compiled, you need to include the library under Link Binary with Libraries in Build Phases. (This screenshot shows the core, imgproc, and highgui libraries. Your cvBlob library would go in the same place.)