[haiku-3rdparty-dev] What I have done with Paladin trying to compile a driver

  • From: "Earl Pottinger" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "earl_colby_pottinger@xxxxxxxxx" for DMARC)
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 22 Jul 2014 13:08:44 -0700

#########################################################################
To test why I can't compile my driver using Paladin I first created the 
smallest none working version of the driver.
#########################################################################


/* CRAM 0.01 --- A basic driver template! */

#include <KernelExport.h>
#include <Drivers.h>
#include <Errors.h>
#include <OS.h>
#include <scsi.h>
#include <Mime.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int32 api_version = B_CUR_DRIVER_API_VERSION;
static const char *sCRAMNames[] = { "disk/cram1/raw",NULL };

static status_t CRAM_open(const char *name, uint32 flags, void **cookie);
static status_t CRAM_read(void *cookie, off_t position, void *read_buffer, 
size_t *read_numBytes);
static status_t CRAM_write(void *cookie, off_t position, const void 
*write_buffer, size_t *write_numBytes);
static status_t CRAM_control(void *cookie, uint32 ioctl_op_code, void *arg, 
size_t length);
static status_t CRAM_close(void *cookie);
static status_t CRAM_free(void *cookie);
static status_t CRAM_select(void *cookie, uint8 event, uint32 ref, selectsync 
*sync);
static status_t CRAM_deselect(void *cookie, uint8 event, selectsync *sync);

static device_hooks sCRAMHooks = { CRAM_open, CRAM_close, CRAM_free, 
CRAM_control, CRAM_read, CRAM_write, CRAM_select, CRAM_deselect, NULL, NULL } ;
status_t init_hardware(void) { return B_OK; }
status_t init_driver(void) { return B_OK; }
void uninit_driver(void) { return; }
const char ** publish_devices(void) { return sCRAMNames; }
device_hooks * find_device(const char* name) { return &sCRAMHooks; }
static status_t CRAM_read(void *cookie, off_t position, void *read_buffer, 
size_t *read_numBytes) { return B_OK; }
static status_t CRAM_write(void *cookie, off_t position, const void 
*write_buffer, size_t *write_numBytes) { return B_OK; }
static status_t CRAM_open(const char *name, uint32 flags, void **cookie) { 
return B_OK; }
static status_t CRAM_close(void *cookie) { return B_OK; }
static status_t CRAM_free(void *cookie) { return B_OK; }
static status_t CRAM_control(void *cookie, uint32 ioctl_op_code, void *arg1, 
size_t length) { return B_ERROR; }
static status_t CRAM_select(void *cookie, uint8 event, uint32 ref, selectsync 
*sync) { return B_OK; }
static status_t CRAM_deselect(void *cookie, uint8 event, selectsync *sync) { 
return B_OK; }


#########################################################################
And this is the makefile settings I used to compile the driver from the 
terminal.
#########################################################################


## BeOS Generic Makefile v2.0 ##

## Fill in this file to specify the project being created, and the referenced

NAME= cram1
TYPE= DRIVER
SRCS= CRAM1.c
RSRCS= 
LIBS= 
LIBPATHS= 
SYSTEM_INCLUDE_PATHS = .
LOCAL_INCLUDE_PATHS = 
OPTIMIZE= NONE
DEFINES= 
WARNINGS = ALL
SYMBOLS = 
DEBUGGER = 
COMPILER_FLAGS =
LINKER_FLAGS =

## include the makefile-engine
include $(BUILDHOME)/etc/makefile-engine


#########################################################################
This is a result reported in the terminal from using the makefile, the driver 
did compile ok. 
#########################################################################


~/Desktop/CRAM/CRAM_0.01> make
[ -d objects.x86-gcc2-release ] || mkdir objects.x86-gcc2-release > /dev/null 
2>&1; \
mkdepend  -I./ -p .c:objects.x86-gcc2-release/%n.o -m -f 
"objects.x86-gcc2-release/CRAM1.d" CRAM1.c
gcc -c CRAM1.c  -I./ -I-  -I. -D_KERNEL_MODE=1 -fno-pic -O0  -Wall 
-Wno-multichar -Wno-ctor-dtor-privacy   -o "objects.x86-gcc2-release/CRAM1.o"
gcc -o "objects.x86-gcc2-release/cram1"         
objects.x86-gcc2-release/CRAM1.o  -nostdlib /boot/system/develop/lib/_KERNEL_ 
/boot/system/develop/lib/haiku_version_glue.o  -L./    
xres -o objects.x86-gcc2-release/cram1  
mimeset -f "objects.x86-gcc2-release/cram1"


#########################################################################
# Now I try using Paladin to compile the driver.  The .PLD file is set to the 
following.
#########################################################################


NAME=CRAM
TARGETNAME=cram1
PLATFORM=Haiku
SCM=none
GROUP=Source Files
EXPANDGROUP=yes
SOURCEFILE=CRAM1.c
SYSTEMINCLUDE=/boot/develop/headers/be
SYSTEMINCLUDE=/boot/develop/headers/cpp
SYSTEMINCLUDE=/boot/develop/headers/posix
SYSTEMINCLUDE=/boot/home/config/include
LIBRARY=/boot/system/lib/libroot.so
LIBRARY=/boot/system/lib/libbe.so
RUNARGS=
CCDEBUG=no
CCPROFILE=no
CCOPSIZE=no
CCOPLEVEL=0
CCTARGETTYPE=0
CCEXTRA=
LDEXTRA=


#########################################################################
When I choose the BUILD->MAKE
 option in the menus I get the following error,
#########################################################################


/boot/system/develop/lib/start_dyn.o: In function `_start':
start_dyn.c:(.text+0x57): undefined reference to `main'
collect2: ld returned 1 exit status


#########################################################################
Then when I examined the project settings found that while I created a 'Driver' 
project that Paladin reported it as an
'Application' project. Selecting a 'Driver' project again the .PLD file had one 
change made.
#########################################################################


CCTARGETTYPE=3


#########################################################################
The BUILD->MAKE
gives the following error,
#########################################################################


gcc: /boot/develop/lib/x86/_KERNEL_: No such file or directory


#########################################################################
Note: I also tried the above builds with a '.cpp' extension.  They still failed 
the same way.
Now the _KERNEL_ error is one I saw before when Haiku first changed it's file 
structure to support PM, the way I got
around it was to copy the 'develop' folder into the ROOT. However after I 
copied the folder to the root '/boot' a lot
of the links were broken. I fixed this by copying over the files original 
pointed to, I also copied _KERNEL_ to the
'x86' folder and once again tried to build the driver with Paladin,  This time 
I got a different error:
#########################################################################


/boot/system/develop/lib/start_dyn.o: In function `_start':
start_dyn.c:(.text+0x57): undefined reference to `main'
collect2: ld returned 1 exit status


#########################################################################
Can anyone make any suggestions.
#########################################################################


Other related posts: