How to build a single module

Forum for software developers to discuss BCI2000 software development
Locked
gchanel
Posts: 5
Joined: 03 Mar 2011, 10:00

How to build a single module

Post by gchanel » 03 Mar 2011, 10:19

Dear all,

first many thanks for this new BCI2000 v3. I did manage to compile BCI2000 quite easily using MinGW and codeblocks under Windows 7 proving that you did a great job to facilitate the task.

Now that I have tested that everything is working I wanted to implement my own module and for this start with a random dirac signal generator (generate a peak randomly with a small probability of occurrence). I thus copied the SignalGenerator, changed its name, and tried to compile it alone. I managed to go through a few obstacles, like how to define MODTYPE with codeblocks (go in the project complier options, and add a variable in "compiler settings / #define" that contains MODTYPE=X with X the type of module you are using) and including the needed headers. Then the problem is to find the dependencies with others .cpp. I spent all my afternoon trying to add the needed files in the project without success. Either there are redundant functions (too much files) or some missing or linkage errors etc... Of course one solution would be to include my module in the cmake created project and recompile all BCI2000 but you would understand that this is not the best solution. My questions are:
- is there any library to use that contains the proper functions (appart from the Qt ones that are already included) ?
- do you have at hand a template for codeblocks project files (like for Borland as suggested here http://www.bci2000.org/wiki/index.php/Programming_FAQ) ?
- is there an easy way to find the needed files (for instance I used the cmake generated project to find the needed .h files easily) ?
- is there a way to use cmake that would solve my problem (I know nothing about it) ?

Thanks for you attention and you answers,

Best regards,

Guillaume Chanel

jhill
Posts: 31
Joined: 17 Nov 2009, 15:15

Re: How to build a single module

Post by jhill » 03 Mar 2011, 13:33

I would recommend starting with a CMakeLists.txt file, patterned on the SignalGenerator's file but defining a different EXECUTABLE_NAME (let's say it's DiracSource). Then, in the parent directory of your DiracSource directory, ensure that CMake performs the appropriate ADD_SUBDIRECTORY. Then re-run cmake.

That would handle a lot of the fiddling you did by hand (setting the MODTYPE, adding the source-acquisition framework files, etc).

The fact that you run or re-run cmake, building or rebuilding a global project file or Makefile, does not mean that you have to build or rebuild the whole of BCI2000. For MinGW make, you would just type `make DiracSource'. For Visual Studio you would just right-click on the "DiracSource" subproject and select "build". I'm not familiar with CodeBlocks, but it must have some similar mechanism.

HTH

gchanel
Posts: 5
Joined: 03 Mar 2011, 10:00

Re: How to build a single module

Post by gchanel » 04 Mar 2011, 05:46

Thanks Jeremy,

perfect answer, I felt that I would have to use cmake at some point.

So everything is working either using the Makefile and mingw32 or using codeblocks and mingw32. In codeblocks you just have to select the correct buildtargets next to the build buttons. I just did not see it before but found it thanks to your pointers.

I will certainly come back with more questions in a few weeks :)

Best,

--
Guillaume Chanel
Postdoctoral Student
University of Geneva

Locked

Who is online

Users browsing this forum: No registered users and 2 guests