Use third party framework in Command Line Tool

Hi. I'm writing a small application for a friend of mine, and basically what it does is lets you put in some information, and then creates and stores that information in an Excel file. However, all of my research suggests that C++ doesn't work nicely with Excel files, so I found a 3rd party framework called LibXL which provides C++ with the ability to create and edit Excel files. My only problem is getting my Command Line Tool to use this framework. I'm not even sure if it is possible, but if someone could help me out, I would really appreciate it!


P.S: I'm using XCode 4.2 to write this application, and I'm using Command Line Tool because the application has to be useable on Windows.

iMAC, Mac OS X (10.7)

Posted on Mar 17, 2012 1:38 PM

Reply
10 replies

Mar 17, 2012 2:28 PM in response to Sean Evans

That last one is an excellent punch line!


>I found a 3rd party framework called LibXL which provides C++ with the ability to create and edit Excel files.


That should be coming with a manual. Some frameworks can be included in their entirety into the program you are writing, where for others you can only reference to it and you have to distribute the framework file(s) along with your own application. This doesn't sound like one, but an external framework may only be meant for GUI functions, in which case you cannot write a Terminal-only program.


But here comes the kicker:


>P.S: I'm using XCode 4.2 to write this application, and I'm using Command Line Tool because the application has to be useable on Windows.


It's possible for you to *write* the program but not to compile it. (Actually, you *can* compile it but then you have a Mac Terminal program, not a Windows one.) Even if you know what you are doing and are happy with sending over the source code, together with instructions on how to compile it under Windows, this implies you would only and *exclusively* use functions that are available in compilers for Windows. That rules out your External framework idea -- unless there is a Windows version available as well (do check for that; if this is an Open Source project, there very well may be.) But you are still programming "blind", and if you get it to work on your Mac (and nevermind the problem with the framework being external, because you won't need to send it over anyway) but your friend canNOT make it work under Windows, you won't know if it's because the Windows version of the compiler doesn't accept the external library, or it's the wrong version, or you accidentally used a Mac-only feature anyway, or the friend does not know how to compile ... et cetera, et cetera.


Best advise is to install VirtualBox (or something similar) on your system, test all you want with XCode but then, after you got it to work, carry over the project into Windows and start a-new.

Mar 17, 2012 2:43 PM in response to Jongware

The application i'm working on does work on windows, I've already tested it, and on Linux as well. And the framework is for linux, mac, and windows. I've already tried including the whole framework, which didn't work obviously. In the readme it says this though:


Using libxl.dylib in command line:


g++ <your_cpp_file> -I<path_to_headers> -L<path_to_library> -lxl


I just have no idea what that means. I'm fairly new to programming, and I've never had to use an external framework before.

Mar 18, 2012 8:15 AM in response to Sean Evans

A framework is just a convenience to encapsute headers and libraries into the same folder. It doesn't change any underlying behaviours. If you install the libxl framework in a standard location, then build with that, it should work fine.


Of course, I'm basically just guessing since you haven't yet said what the actual problem is. Until that happens, the best anyone can do is provide suggestions about how things are supposed to work.

Mar 18, 2012 9:17 AM in response to etresoft

You're right, I don't know how I keep overlooking stating what my actual problem is. I apologize, my thoughts have been pretty scattered lately.


So here is where I have the problem: even after adding the framework to my XCode project by going to File > Add Files to Project, XCode tells me that it can't find the libxl.h file. I copy and pasted one of the examples that came with the framework, and at the top it has this:


#include "libxl.h"


but XCode says "'libxl.h' file not found". Here is a screenshot of what is happening. This is one of the examples straight from the libxl framework.


User uploaded file

Mar 18, 2012 11:20 AM in response to Sean Evans

Try #include "LibXL/libxl.h". That wouldn't be cross-platform though. In Xcode's compiler settings, you can specify the "-I" include setting and the "-L" linker setting. You will still need to make sure libxl.dylib is somewhere in a search path.


Before you mentioned doing:


g++ <your_cpp_file> -I<path_to_headers> -L<path_to_library> -lxl


What happens when you do that? Xcode is optimized for larger iOS and Mac projects.

Mar 18, 2012 12:02 PM in response to etresoft

I tried using #include "LibXL/Libxl.h" before, and while XCode stops telling me that it couldn't find the file, this is what happens:




User uploaded file

I'm not entirely sure what you mean by what happens when I do that. g++ <your_cpp_file> -I<path_to_headers> -L<path_to_library> -lxl was something that I found in the readme for the framework, but I'm not sure what it means or what to do with it. Is it a command that I should run in Terminal?

Mar 18, 2012 1:31 PM in response to Sean Evans

I took a look at that library. It is very poorly done. The C++ examples will not compile. The provided framework file is not valid. It seems to work, but I sure wouldn't deliver any code with that. My official suggestion is to find another library.


If you really want to use it, you will have to hack it up to make it work. You need to copy all the files from "include_cpp" into the "Headers" folder in the "libXL.framework" folder. Then, that framework folder needs to be copied somewhere on the system where it can be found, such as /Library/Frameworks or ~/Library/Frameworks.


I suggest just write Excel XML documents instead. I think the original XLS format is pretty simple too.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use third party framework in Command Line Tool

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.