Argonne National Laboratory

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  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
<== Date ==> <== Thread ==>

Subject: RE: linking C-functions to state machines
From: Mark Rivers <rivers@cars.uchicago.edu>
To: "'kowalski-jankowalski.1986'" <kowalski-jankowalski.1986@o2.pl>, "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Tue, 6 Oct 2015 18:07:58 +0000
I have fixed your Makefile.   Here is the patch.  This version works for me.  I added testFunc.c to NAZWASupport and added NAZWASupport to sncProgram_LIBS.

#####################################################
corvette:example/exampleApp/NAZWASrc>diff -U3 Makefile.orig Makefile
--- Makefile.orig       2015-10-06 13:05:15.858083606 -0500
+++ Makefile    2015-10-06 13:00:00.318191828 -0500
@@ -21,14 +21,13 @@
 #NAZWA_DBD += xxx.dbd
 
 # Add all the support libraries needed by this IOC
-NAZWA_LIBS_DEFAULT += testFunc
+NAZWASupport_SRCS += testFunc.c
 
 # 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
@@ -47,6 +46,7 @@
     sncProgram_SNCFLAGS += +m
     sncProgram_SRCS += sncProgram.st
     sncProgram_LIBS += seq pv
+    sncProgram_LIBS += NAZWASupport
     sncProgram_LIBS += $(EPICS_BASE_HOST_LIBS)
 endif
 
@@ -59,6 +59,3 @@
 #----------------------------------------
 #  ADD RULES AFTER THIS LINE
#####################################################

Mark


-----Original Message-----
From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of kowalski-jankowalski.1986
Sent: Tuesday, October 06, 2015 10:43 AM
To: tech-talk@aps.anl.gov
Subject: linking C-functions to state machines

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





References:
linking C-functions to state machines kowalski-jankowalski.1986

Navigate by Date:
Prev: linking C-functions to state machines kowalski-jankowalski.1986
Next: Area Detector: ADPointGrey 2-1 and Blackfly GIGE on Linux John Dobbins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
Navigate by Thread:
Prev: linking C-functions to state machines kowalski-jankowalski.1986
Next: Area Detector: ADPointGrey 2-1 and Blackfly GIGE on Linux John Dobbins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·