From ff0a041dd86d597930d9b2c870458389eda89c69 Mon Sep 17 00:00:00 2001
From: scipio Currently, the only platform TOSSIM supports is the
+ Currently, the only platform TOSSIM supports is the
micaz. You should see output similar to this: Depending on what OS you are using and what packages are installed, TOSSIM may
+ not properly compile on the first try. Appendix A
+ addresses some of the common causes and gives possible solutions. Compiling TOSSIM has five basic steps. Let's go through
them one by one. < Previous Lesson | Top | Next
Lesson >
+
TOSSIM is a C/C++ shared library with an optional
+ Python translation layer. Almost all of the problems
+ encountered in compiling TOSSIM are due to C linking
+ issues. If you don't know what a linker is (or have never
+ linked a C program), then chances are the rest of this
+ appendix is going to be cryptic and
+ incomprehensible. You're best off starting with learning
+ about linkers, why they
+ are needed, and how you use the
+ gcc/g++ compilers to link code. Generally, when compiling TOSSIM using make micaz sim,
+ one of four things can go wrong: We'll visit each in turn. It turns out that the Cygwin and Linux versions of gcc/g++
+ have different command-line flags and require different options
+ to compile TOSSIM properly. For example, telling the Linux
+ compiler to build a library requires -fPIC while
+ the Cygwin is -fpic. If you're using Cygwin and
+ you see the output look like this:
+
+
+
+
mkdir -p build/micaz
placing object files in build/micaz
writing XML schema to app.xml
@@ -100,8 +98,15 @@
linking into shared object ./_TOSSIMmodule.so
g++ -shared build/micaz/pytossim.o build/micaz/sim.o build/micaz/tossim.o -lstdc++ -o _TOSSIMmodule.so
copying Python script interface TOSSIM.py from lib/tossim to local directory
-
+ Appendix A: Troubleshooting TOSSIM compilation
+
+
+
+
+ You are using Cygwin but the sim compilation option
+ can't figure this out
+
+
+ ncc -c -shared -fPIC -o build/micaz/sim.o ...
+
+
+ rather than
+
+
+ ncc -c -DUSE_DL_IMPORT -fpic -o build/micaz/sim.o ...
+
+
+ then you have encountered this problem. The problem
+ occurs because Cygwin installations do not have a
+ consistent naming scheme, and so it's difficult for the
+ compilation toolchain to always figure out whether it's
+ under Linux or Cygwin.
Symptom: You're running cygwin but you see the + -fPIC rather than -fpic option being + passed to the compiler.
+ +Solution: Explicitly set the OSTYPE environment + variable to be cygwin either in your .bashrc + or when you compile. For example, in bash:
+ ++$ OSTYPE=cygwin make micaz sim ++ + or in tcsh + +
+$ setenv OSTYPE cygwin +$ make micaz sim ++ +
Note that often this problem occurs in addition to + other ones, due to using a nonstandard Cygwin + installation. So you might have more problems to track + down.
+ +If when you compile you see lots of errors such as + "undefined reference to" or "Python.h: No such file or + directory" then this might be your problem. It is a + subcase of the more general problem of TOSSIM not being + able to find needed libraries and files.
+ +Compiling Python scripting support requires that you + have certain Python development libraries installed. First, check + that you have Python installed:
+ ++$ python -V +Python 2.4.2 ++ +
In the above example, the system has Python 2.4.2. If + you see "command not found" then you do not have Python + installed. You'll need to track down an RPM and install + it. TOSSIM has been tested with Python versions 2.3 and + 2.4. You can install other versions, but there's no + assurance things will work.
+ +In addition to the Python interpreter itself, you need + the libraries and files for Python development. This is + essentially a set of header files and shared libraries. If + you have the locate command, you can type + locate libpython, or if you don't, you can look + in /lib, /usr/lib and + /usr/local/lib. You're looking for a file with a + name such as libpython2.4.so and a file named + Python.h. If you can't find these files, then you + need to install a python-devel package.
+ + +Symptom: Compilation can't find critical files + such as the Python interpreter, Python.h or a + Python shared library, and searching your filesystem shows + that you don't have them.
+ +Solution: Installed the needed files from Python + and/or Python development RPMS.
+ +If you have all of the needed files, but are still + getting errors such as "undefined reference" or "Python.h: + No such file or directory", then you have the next + problem: they're on your filesystem, but TOSSIM can't find + them.
+ +You've found libpython and Python.h, but when TOSSIM compiles + it says that it can't find one or both of them. If it can't + find Python.h then compilation will fail pretty early, as g++ won't + be able to compile the Python glue code. If it can't find the python + library, then compilation will fail at linking, and you'll see + errors along the lines of "undefined reference to __Py...". You + need to point the make system at the right place.
+ +Open up support/make/sim.extra. If the make + system can't find Python.h, then chances are it isn't in + one of the standard places (e.g., /usr/include). You need to tell + the make system to look in the directory where Python.h is with + a -I option. At the top of sim.extra, under the PFLAGS entry, + add + +
+CFLAGS += -I/path ++ + where /path is the path of the directory where Python.h + lives. For example, if it is in /opt/python/include, + then add CFLAGS += -I/opt/python/include. + +
If the make system can't find the python library for + linking (causing "undefined reference") error messages, + then you need to make sure the make system can find + it. The sim.extra file uses two variables to find the + library: PYDIR and PYTHON_VERSION. It + looks for a file named libpython$(PYTHON_VERSION).so. So + if you have Python 2.4 installed, make sure that + PYTHON_VERSION is 2.4 (be sure to use no spaces!) and if + 2.3, make sure it is 2.3.
+ +Usually the Python library is found in + /usr/lib. If it isn't there, then you will need + to modify the PLATFORM_LIB_FLAGS variable. The + -L flag tells gcc in what directories to look for + libraries. So if libpython2.4.so is in + /opt/python/lib, then add + -L/opt/python/lib to the + PLATFORM_LIB_FLAGS. Note that there are three + different versions of this variable, depending on what OS + you're using. Be sure to modify the correct one (or be + paranoid and modify all three). + + +
Symptom: You've verified that you have the + needed Python files and libraries, but compilation is + still saying that it can't link to them ("undefined + reference") or can't find them.
+ +Solution: Change the sim.extra file to point to + the correct directories.
+ +Symptom: You get a "This python version requires + to use swig with the -classic option" error message.
+ +Solution: Install SWIG and regenerate Python + support with the sing-generate script in + tos/lib/tossim, or install a different version of + Python.
+ +Hopefully, these solutions worked and you can get back + to compiling, If not, then you + should email tinyos-help.
-- 2.39.2