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

Subject: Re: Problem compiling EPICS ioc with libusb
From: Sam de Jong <srdejong@uvic.ca>
To: Michael Westfall <mwestfal@gemini.edu>
Cc: "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Fri, 23 Jun 2017 08:40:52 -0700
Thank you for your assistance. I was able to successfully compile after making your suggestions

-Sam


-------- Original message --------
From: Michael Westfall
Date:2017-06-23 8:06 AM (GMT-07:00)
To:
Cc: Sam de Jong , tech-talk@aps.anl.gov
Subject: Re: Problem compiling EPICS ioc with libusb

Right.

I was just able to compile successfully with these in my Makefile:

testSupport_SRCS += DI-2108-P.cpp
testSupport_SYS_LIBS += usb-1.0


Also, your added source files DI-2108-P.cpp and DI-2108-P-h need to be in the .../testApp/src directory.

Here is the whole  Makefile:

TOP=../..

include $(TOP)/configure/CONFIG
#----------------------------------------
#  ADD MACRO DEFINITIONS BELOW HERE

# xxxRecord.h will be created from xxxRecord.dbd
DBDINC += xxxRecord

# Install xxxSupport.dbd into <top>/dbd
DBD += xxxSupport.dbd

# Build an IOC support library
LIBRARY_IOC += testSupport

# Compile and add the code to the support library
testSupport_SRCS += xxxRecord.c
testSupport_SRCS += devXxxSoft.c
testSupport_SRCS += DI-2108-P.cpp

# Link locally-provided code into the support library,
# rather than directly into the IOC application.
# This is required for Windows DLL builds.
testSupport_SRCS += dbSubExample.c
testSupport_SRCS += testHello.c
testSupport_SRCS += initTrace.c
testSupport_SYS_LIBS += usb-1.0
testSupport_LIBS += $(EPICS_BASE_IOC_LIBS)

# Build the IOC application
PROD_IOC = test

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

# test.dbd will include these files:
test_DBD += base.dbd
test_DBD += xxxSupport.dbd
test_DBD += dbSubExample.dbd
test_DBD += testHello.dbd
test_DBD += initTrace.dbd

# test_registerRecordDeviceDriver.cpp derives from test.dbd
test_SRCS += test_registerRecordDeviceDriver.cpp

# Build the main IOC entry point where needed
test_SRCS_DEFAULT += testMain.cpp
test_SRCS_vxWorks += -nil-

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

# Link in the code from our support library
test_LIBS += testSupport


On Fri, Jun 23, 2017 at 4:45 AM, Hinko Kocevar <hinkocevar@gmail.com> wrote:
I think he needs 

test_SYS_LIBS += usb-1.0

'Cause header file pulls in libisb-1.0/libusb.h


Cheers,
Hinko

On Fri, 23 Jun 2017 at 01:21, Mark Rivers <rivers@cars.uchicago.edu> wrote:

You need to add libusb to testApp/src/Makefile like this:

 

test_SYS_LIBS += usb

 

Mark

 

 

From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of Sam de Jong
Sent: Thursday, June 22, 2017 6:17 PM
To: tech-talk@aps.anl.gov
Subject: Problem compiling EPICS ioc with libusb

 

Hello EPICS tech-talk,

    I am trying to compile an EPICS IOC with libusb included (I am on a linux platform running ubuntu 14.04 and EPICS base 3.14-3.14.12.3 ).

    I created the ioc using

    makeBaseApp.pl -t example test   
    makeBaseApp.pl -t example -i -a linux-x86_64 test

and was able to run make with no issues.

I added the header files for a class I created which interfaces with a usb device (these are included in this email) by adding this line to /testAPP/src/testMain.cpp:

    #include "DI-2108-P.cpp"

when I try to make, I get this output:

make -C ./configure install
make[1]: Entering directory `/media/Extra_Space/work/testIOC/configure'
make -C O.linux-x86_64 -f ../Makefile TOP=../.. T_A=linux-x86_64 install
make[2]: Entering directory `/media/Extra_Space/work/testIOC/configure/O.linux-x86_64'
perl ../../../epics/epics3.14-3.14.12.3/bin/linux-x86_64/convertRelease.pl checkRelease
make[2]: Leaving directory `/media/Extra_Space/work/testIOC/configure/O.linux-x86_64'
make[1]: Leaving directory `/media/Extra_Space/work/testIOC/configure'
make -C ./testApp install
make[1]: Entering directory `/media/Extra_Space/work/testIOC/testApp'
make -C ./src install
make[2]: Entering directory `/media/Extra_Space/work/testIOC/testApp/src'
make -C O.linux-x86_64 -f ../Makefile TOP=../../.. T_A=linux-x86_64 install
make[3]: Entering directory `/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64'

/usr/bin/g++ -c  -D_POSIX_C_SOURCE=199506L -D_POSIX_THREADS -D_XOPEN_SOURCE=500           -D_X86_64_  -DUNIX  -D_BSD_SOURCE -Dlinux  -D_REENTRANT   -O3 -g   -Wall      -m64      -MMD -I. -I../O.Common -I. -I.. -I../../../include/os/Linux -I../../../include -I../../../../epics/epics3.14-3.14.12.3/include/os/Linux -I../../../../epics/epics3.14-3.14.12.3/include       ../testMain.cpp
In file included from ../testMain.cpp:14:0:
../DI-2108-P.cpp: In member function ‘std::vector<double> DI_2108_P::getReadings()’:
../DI-2108-P.cpp:202:7: warning: variable ‘r’ set but not used [-Wunused-but-set-variable]
   int r; //for return values
       ^
/usr/bin/g++ -o test  -L/media/Extra_Space/work/epics/epics3.14-3.14.12.3/lib/linux-x86_64 -L/media/Extra_Space/work/testIOC/lib/linux-x86_64        -m64              test_registerRecordDeviceDriver.o testMain.o    -ltestSupport -lrecIoc -lsoftDevIoc -lmiscIoc -lrsrvIoc -ldbtoolsIoc -lasIoc -ldbIoc -lregistryIoc -ldbStaticIoc -lca -lCom  
testMain.o: In function `DI_2108_P::Initialize()':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:37: undefined reference to `libusb_init'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:42: undefined reference to `libusb_set_debug'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:44: undefined reference to `libusb_get_device_list'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:51: undefined reference to `libusb_open_device_with_vid_pid'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:56: undefined reference to `libusb_free_device_list'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:58: undefined reference to `libusb_kernel_driver_active'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:63: undefined reference to `libusb_claim_interface'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:60: undefined reference to `libusb_detach_kernel_driver'
testMain.o: In function `DI_2108_P::close()':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:82: undefined reference to `libusb_release_interface'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:89: undefined reference to `libusb_close'
testMain.o: In function `DI_2108_P::sendMessage(std::string)':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:114: undefined reference to `libusb_bulk_transfer'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:118: undefined reference to `libusb_bulk_transfer'
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:120: undefined reference to `libusb_strerror'
testMain.o: In function `DI_2108_P::getReadings()':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:208: undefined reference to `libusb_bulk_transfer'
testMain.o: In function `DI_2108_P::reset()':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:74: undefined reference to `libusb_reset_device'
testMain.o: In function `DI_2108_P::close()':
/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64/../DI-2108-P.cpp:90: undefined reference to `libusb_exit'
collect2: error: ld returned 1 exit status
make[3]: *** [test] Error 1
make[3]: Leaving directory `/media/Extra_Space/work/testIOC/testApp/src/O.linux-x86_64'
make[2]: *** [install.linux-x86_64] Error 2
make[2]: Leaving directory `/media/Extra_Space/work/testIOC/testApp/src'
make[1]: *** [src.install] Error 2
make[1]: Leaving directory `/media/Extra_Space/work/testIOC/testApp'
make: *** [testApp.install] Error 2

 

Do you have any idea what might be causing this issue? I've tried googling around and haven't found anything helpful.

Thank you for your assistance,
-Sam de Jong

   

   

--
.. the more I see the less I believe.., AE AoR



--
Mike Westfall
Control Systems Software Engineer



Navigate by Date:
Prev: RE: modbus write 2 16 bits holding registers with modbus function 16 Mark Rivers
Next: Re: modbus write 2 16 bits holding registers with modbus function 16 Claudio Lambert
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
Navigate by Thread:
Prev: Re: Problem compiling EPICS ioc with libusb Michael Westfall
Next: modbus write 2 16 bits holding registers with modbus function 16 Claudio Lambert
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
ANJ, 23 Jun 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·