EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: linking C-functions to state machines
From: "kowalski-jankowalski.1986" <[email protected]>
To: [email protected]
Date: Tue, 06 Oct 2015 17:42:31 +0200
Dear Tech-talkers,
I am developing an IOC that will have few state machines often calling function that I have prepared in C.

Minimalistic reproduction of my problem:
When I try to compile my code, I get linker error: NAZWAApp/src/O.linux-x86_64/./../sncExample.stt:15: undefined reference to `testFunction'
collect2: error: ld returned 1 exit status.
If I comment line where I call that function, it compiles and works.

If I understand correctly, I am doing something wrong when telling EPICS to link my C file, I have tried playing with makefile in src, but failed. How should it be done?

relevant files from src:
Makefile:
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
#  ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#=============================
# Build the IOC application
PROD_IOC = NAZWA
# Build an IOC support library
LIBRARY_IOC += NAZWASupport

NAZWA_LIBS += NAZWASupport

# NAZWA.dbd will be created and installed
DBD += NAZWA.dbd

# NAZWA.dbd will be made up from these files:
NAZWA_DBD += base.dbd

# Include dbd files from all support applications:
#NAZWA_DBD += xxx.dbd

# Add all the support libraries needed by this IOC
NAZWA_LIBS_DEFAULT += testFunc

# NAZWA_registerRecordDeviceDriver.cpp derives from NAZWA.dbd
NAZWA_SRCS += NAZWA_registerRecordDeviceDriver.cpp

# Build the main IOC entry point on workstation OSs.
NAZWA_SRCS_DEFAULT += NAZWAMain.cpp
NAZWA_SRCS_DEFAULT += testFunc.c
NAZWA_SRCS_vxWorks += -nil-

# Add support from base/src/vxWorks if needed
#NAZWA_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary

ifneq ($(SNCSEQ),)
    # Build sncNAME into NAZWASupport
    sncExample_SNCFLAGS += +r
    NAZWA_DBD += sncExample.dbd
    NAZWASupport_SRCS += sncExample.stt
    NAZWASupport_LIBS += seq pv
    NAZWA_LIBS += seq pv

    # Build sncProgram as a standalone program
    PROD_HOST += sncProgram
    sncProgram_SNCFLAGS += +m
    sncProgram_SRCS += sncProgram.st
    sncProgram_LIBS += seq pv
    sncProgram_LIBS += $(EPICS_BASE_HOST_LIBS)
endif

# Finally link to the EPICS Base libraries
NAZWA_LIBS += $(EPICS_BASE_IOC_LIBS)

#===========================

include $(TOP)/configure/RULES
#----------------------------------------
#  ADD RULES AFTER THIS LINE


#####
sncExample.stt: 

program sncNAME

%{
#include <testFunc.h>
}%


ss ss1 {
    state init {
    	entry {
    		printf("sncNAME: entered init\n");
    	}
		when (delay(5)) {
		    printf("sncNAME: Will try testFunction now\n");
		    testFunction();
		} state init
    }
}
######
testFunc.h:

void testFunction();
######
testFunc.c:

#include <stdio.h>
void testFunction(){
	printf("Test Function worked/n");
}
####

Regards
Jan Kowalski




Replies:
RE: linking C-functions to state machines Mark Rivers

Navigate by Date:
Prev: RE: caqtdm "intelligent" applications Williams Jr., Ernest L.
Next: RE: linking C-functions to state machines Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: caqtdm "intelligent" applications Williams Jr., Ernest L.
Next: RE: linking C-functions to state machines Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024