Spliting function library from main using #include

2 replies [Last post]
Title: NooBot
Joined: 05/02/2013
BotPoints: 5
User offline. Last seen 9 years 21 weeks ago.

In the previous KISS-C software we could split our code into 2 different .c files (e.x. include "samplecode.c") to store our functions and keep it separate from the main. In the new KISS IDE 4.0.5 Platform we cant do that. Is there any possible way to do that in the current KISS IDE?

v-v-v-MAIN & ERROR-v-v-v

// Created on Thu May 2 2013
#include "TestLib.c"

int main()
printf("Hello, World!\n");
return 0;

TestMain.c.o: In function `__set_no_stdout_buffer':
TestMain.c:(.text+0x0): multiple definition of `__set_no_stdout_buffer'
/tmp/700101003546.kovan-serial/:/Users/User 1TestLib.c.o:TestLib.c:(.text+0x0): first defined here
TestMain.c.o: In function `printMessage':
TestMain.c:(.text+0x34): multiple definition of `printMessage'
/tmp/700101003546.kovan-serial/:/Users/User 1TestLib.c.o:TestLib.c:(.text+0x34): first defined here
collect2: ld returned 1 exit status


// Created on Thu May 2 2013

void printMessage()
printf("Ross's Function\n");

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
BotPoints: 1168
User offline. Last seen 7 years 20 weeks ago.

Files which are included using #include should have a .h extension, not .c. Note that in C programming, it is usually best practice to have function code in .c files, with function prototypes in .h files, and use a linker rather than #include to merge the code together. This makes the compilation process much more efficient. I'm not sure if KISS-IDE supports linking yet... Braden, can you comment on this? In any event, it's acceptable for Botball purposes to just have library code in .h files, even though professional C programmers don't like it.

tldr: rename your .c library to a .h file.

There are also reportedly path issues with library files on the Link... you may need to specify the full path to the flash drive; I'm not sure if KIPR fixed this yet.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Title: NooBot
Joined: 03/23/2012
BotPoints: 36
User offline. Last seen 8 years 26 weeks ago.

this is what our team discovered after talking to someone from Kipr.

If you are compiling with with a usb or wifi target. Not sure about using a flash drive

  1. put all functions and prototypes in a ".h" file
  2. Compile the ".h" file to the with the usb/wifi
  3. The compile should complete with a message of "error: No terminals detected from compilation".
  4. include the ".h" file with a #include "file.h" directive in your C program
  5. Now compile the ".c" file

Hope this helps

Brad A.
Team 13-0624
Fairfield, IL