-
Notifications
You must be signed in to change notification settings - Fork 4
Compilation
Image:MediaWikiSidebarLogo.png SWObjects Semantic Web Library - Compilation
Start by checking out the swobjects library:
git clone https://github.com/ericprud/SWObjects.gitThis checks out the main branch (master in git parlance) into a newly-created swobjects directory. You can choose the functionality you want, and thereby, the requirements:
core | SPARQL language | SQL access | language extensions | package |
---|---|---|---|---|
☑ | ☐ | ☐ | ☐ | C compiler |
☐ | ☑ | ☐ | ☐ | boost |
☐ | ☐ | ☑ | ☐ | MySQL |
☐ | ☐ | ☐ | ☑ | flex/bison |
Debian: Installing all of these is fairly trivial: sudo apt-get install libboost-dev bison flex libmysqlclient-dev.
Mac OS X: You can http://www.macports.org/install.php install MacPorts and sudo /opt/local/bin/port install boost mysql5-devel (about 1 hour 'cause MacPorts builds everything from source).
Don't forget to edit CONFIG to add /opt/local/include/ and /opt/local/include/mysql5 to the includes, and /opt/local/lib/ and /opt/local/lib/mysql5/mysql to the libs. Make sure to set LINK to DYNAMIC.
Mac using homebrew
- Connect to https://developer.apple.com/downloads/index.action using someone's borrowed Apple Dev ID.
- Select only ☑ Developer Tools. Search for "Command Line Tools".
- Download the one for your kitty cat.
-
for remote installation:
- scp Downloads/xcode… targetMachine:
- hdiutil mount xclode…
- sudo installer -pkg /Volumes/Command\ Line\ Tools\ \(…\)/Command\ Line\ Tools\ \(…\).mpkg -target /
- hdiutil detach /Volumes/Command\ Line\ Tools\ \(Lion\)/
- # hopefully you won't already have a /usr/local/ directory
- ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" # per http://mxcl.github.com/homebrew/
- brew doctor
- brew install git
Any modern g++ will work. SWObjects for windows compiles with Visual Studio 8, and presumably, later.
Debian: apt-get install mysql-dev
Windows: Install http://dev.mysql.com/downloads/mysql/5.5.html Win32 MSI Installer (or 64-bit, if you are using MS Developer Studio 2010 on a 64 bit machine) and select "Custom" to enable "Developer Components". (You may want to install a server to play with as well.) You must add the newly created directory to Developer Studio's Tools::Options::Projects and Solutions::VC++ Directories::Include Files: C:\Program Files\MySQL\MySQL Server 5.5\include and add \lib to the Library Files. The 32bit binaries may appear instead in C:\Program Files\...
.
In order to run your compiled executable, you must copy libmysql.dll and libmysql.pdb to a directory in your path. You can copy them to C:\Program Files\MySQL\MySQL Server 5.5\bin if you let the MySQL installer put that directory in the path. Install shield may not give you permission to do this from the command line, in which case you can use the Windows Explorer (Windows key + 'E').
Debian: sudo apt-get install bison flex.
Windows: Run the http://gnuwin32.sourceforge.net/packages/bison.htm GnuWin32 Bison Setup and http://gnuwin32.sourceforge.net/packages/flex.htm GnuWin32 FlexSetup and install into C:\GnuWin32. (If you include spaces in the directory name, e.g. the default C:\Program FilesGnuWin32\, you will see "m4: cannot open `File\GnuWin32/share/bison': No such file or directory".) Cygwin may have an older bison, see Bison 2 vs. Bison 1. You can install CygWin and select bison and flex from the developer tools.
The flex templates generate suggest parentheses around ‘&&’ within ‘||’
warnings if you turn the warnings all the way up. You can avoid this by patching the template /usr/share/bison/location.cc
line 121 to include disambiguating parens:
- || pos1.filename && pos2.filename && *pos1.filename == *pos2.filename) + || (pos1.filename && pos2.filename && *pos1.filename == *pos2.filename))
Debian: apt-get install libboost-dev. If you elect to build boost, you can:
- install libbz2-dev
- download a recent version of boost (most recently tested is 1.49)
- uncompress it, cd to the new dir, pick some install directory; I use libboost.inst, and issue this command to start the compilation:
./bootstrap.sh --prefix=../libboost.inst --exec-prefix=../libboost.inst \ --libdir=../libboost.inst/lib --includedir=../libboost.inst/include \ --without-icu && ./b2 install
- edit the CONFIG file in the root of the SWObjects checkout to add paths to the boost dir:
INCLUDES=-I../libboost.inst/include LIBS=-L../libboost.inst/lib LD_LIBRARY_PATH=../libboost.inst/lib
Windows: Run the boostpro installer, accept defaults for download source, and in the 4th dialog, select a version of Visual Studo and the Multithreaded and Multithreaded debug variants. This installer doesn't know what you've already installed (you have to keep track) and no ETA (maybe 20 mininutes downloading over a cable modem, 5 minutes unpacking). The libraries have been tested with Visual Studio 2005/MSVC++8.0 and Visual Studio 2008/MSVC++9.0. Help::About Visual Studio will tell you the version of the C++ compiler you are running.
You can minimize the time (5 mins) and space (275M): in the 5th dialog, expand e.g. Boos Filesystem/VC8.0 and select Multithreaded (debug) DLL.
As of 1 Nov 2009, the boostpro 1.40 setup excludes some VC8 libraries. This table shows you what you need now and what SWObjects may need later:
now | later | skip | package |
---|---|---|---|
☑ | ☐ | ☐ | DateTime |
☑ | ☐ | ☐ | Filesystem |
☐ | ☑ | ☐ | Graph |
☑ | ☐ | ☐ | IOStreams |
☐ | ☐ | ☑ | Math |
☐ | ☑ | ☐ | ProgramOptions |
☐ | ☐ | ☑ | Python, Serialization |
☑ | ☐ | ☐ | Regex |
☐ | ☐ | ☑ | Serialization |
☐ | ☑ | ☐ | Serialization (wide char) |
☐ | ☑ | ☐ | Signals |
☑ | ☐ | ☐ | System |
☐ | ☑ | ☐ | Test (execution monitor) |
☐ | ☑ | ☐ | Test (test execution monitor) |
☑ | ☐ | ☐ | Test (unit test framework) |
☑ | ☐ | ☐ | Thread |
☐ | ☐ | ☑ | Wave |
You also get to select Add to path; the build has been tested with this enabled.
You now need to tell Visual Studio where to find the boost libraries which you have just installed.
Tools::Options::Projects and Solutions::VC++ Directories::Library Files: $(ProgramFiles)\boost\boost_1_39\lib <span style="color: red; ">// needs '\' after $(ProgramFiles)</span> Tools::Options::Projects and Solutions::VC++ Directories::Include Files: $(ProgramFiles)\boost\boost_1_39 // needs '\' after $(ProgramFiles)You also need to tell the system where to find the boost dlls. In the Windows Explorer, left click My Computer and select Properties. You can set Advanced::Environment Variables::System Variables::PATH to include
C:\Program Files\boost\boost_1_39\lib
or copy the DLLs from that directory into e.g. C:\pathins
and include that in the path.
You can now start Visual Project, open existing project, and select the SWObjects.sln file in the swobjects directory.
For hashing and crypto functions, you'll need cryptopp. These instructions worked for version 5.6.1:
Download the [http://www.cryptopp.com/cryptopp561.zip zip] Unzip it in a newly-created directory; I build in a directory which is next to the SWObjects source. Set CRYPTLIB to the relative or absolute path in CONFIG (e.g. '''CRYPTLIB= ../cryptopp561'''). cd to the new directory Downloads/cryptopp561 cryptopp ships with a Makefile called GNUmakefile. The build targets start at line 134. If you will want to use dynamic library extension functions, uncomment line 4 "# CXXFLAGS += -fPIC". '''make all''' takes 5 mins on a 1.8GHz single core (or '''make test''' if you'd like to see it count on it's fingers for an extra minute). return to the SWObjects checkout directory. edit CONFIG set CRYPTLIB (name may change somewhat) to point to the new directory, e.g. CRYPTLIB= ../../Downloads/cryptopp561 (note that relative paths work.) ignore the unpleasant warnings about e.g. unsigned < 0 and unconstructed base classes (or fix them and send me the patches to include here to make everyone's lives nicer.)
On unix, it's simple; select the tool you want, e.g. STtransformer, and type:
make bin/sparql
On Windows, Visual Studio has a list of projects. First build libSWObjects (building another project would in theory see the dependancy on libSWObjects, but not the generated parser header files), then the tool you want.
Here are a bunch of errors and the corresponding fixes:
lib/MapSetParser/MapSetParser.ypp:49:2: error: #endif without #if lib/MapSetParser/MapSetParser.ypp:50:1: error: unterminated #ifndef In file included from lib/MapSetParser/MapSetParser.ypp:176: ...indicates that you are probably running Bison2. As Bison1 is still the most common (and comes with CygWin), the parsers are set up to use Bison1. You can install an earlier Bison, or change the section marker lines matching
%{ /*** C/C++ Declarations ***/and the corresponding end-of-section markers ("%}") to the Bison2 pattern "%code requires { ... }
t:\lib\sparqlfedparser\sparqlfedparser.ypp(221) : fatal error C1083: Cannot open include file: '../SPARQLfedScanner.hpp': No such file or directorySelecting "Rebuild" in Visual Studio causes it to delete the Scanner.hpp files. You need to get them from the distribution again.
Windows looks for DLLs in the %PATH%. Errors like
The application has failed to start because boost_unit_test_framework-vc80-mt-gd-1_39.dll was not found. Re-installing the application may fix this problem.indicate that a DLL (in this case a boost DLL) is not in the path. Any of the following will work to place your boost DLLs in the path:
edit the path in your shell (set PATH=%PATH%;C:\Program Files\boost\boost_1.39\lib) edit the path for the system (right click My Computer, select properties::Advanced::Environment Variables::System Variables); don't forget to inlcude a ';' between path components. copy the DLL (for instance, from C:\Program Files\boost\boost_1.39\lib) to the working directory copy (shortcuts to) the DLL to some directory and add it to the path.
lib/SPARQLfedParser/position.hh: In function ‘bool w3c_sw::operator==(const w3c_sw::position&, const w3c_sw::position&)’: lib/SPARQLfedParser/position.hh:136: warning: suggest parentheses around && within ||/usr/local/share/bison/location.cc should have extra parens around an "&&": s/ || pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)
/ || (pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)) /
The biggest challenge in compiling is which version of Bison you are using. Bison 2 is not backwards compatible with Bison 1 and these instructions assume Bisone 2. See bison code directive for instructions on compiling with Bison 1. While you are playig with the bison issues on unix, you can force compilation with
make -k -Wlib/SPARQLfedParser/SPARQLfedParser.ypp t_DAWG
and on windows you can select SWObjects::
Do not use the flex on http://gnuwin32.sourceforge.net/packages/flex.htm as it is badly out of date.
bison -o lib/SPARQLfedParser/SPARQLfedParser.cpp lib/SPARQLfedParser/SPARQLfedParser.ypp lib/SPARQLfedParser/SPARQLfedParser.ypp:50.1-5: invalid directive: `%code' lib/SPARQLfedParser/SPARQLfedParser.ypp:50.7-14: syntax error, unexpected identifiermeans you're using bison 1 instead of bison 2. You can change
%code requires { /*** C/C++ Declarations ***/to
%{ /*** C/C++ Declarations ***/and the corresponding close brace (after the closing of namespace w3c_sw)
} // namespace w3c_sw } /*** BEGIN SPARQLfed - Change the grammar's tokens below ***/
to
"%}".Media:Example.ogg