Missing LIB files. BCI2000 + Visual Studio

This forum deals with BCI2000 configuration issues.
Locked
skvpe
Posts: 9
Joined: 13 May 2014, 10:30

Missing LIB files. BCI2000 + Visual Studio

Post by skvpe » 11 Nov 2014, 03:14

Hello,

I am a beginner in BCI2000 environment and I request your help in the following issue.

I am running BCI2000 in MS Visual Studio 2010 and I followed the instructions given in wiki. I got BCI2000.sln as mentioned there and was able to build all and generate exe files for all projects. Next I want to run BCI2000 with CyUSB USB controller and create a signal source which will acquire data from CyUSB device. So I added corresponding header and cpp files in 'SignalGenerator' project.

After building, I got linker error saying it cannot find .lib files in folders BCI2000src\build\cmake\frameworks\...

I found out 5cmake files (LibTiny,Core,SigProcModule,SigSrcModule,AppModule) whose *.lib files don't exist. All the projects have this 'frameworks\..\*.lib' files mentioned in Properities->Linker->Include->Additional Dependencies in VC++

Then I tried to CMake LibTiny using the GUI->
Source code = ../frameworks/LibTiny.
Generated using = Visual Studio 2010 by default native compilers

Error: Project files may be invalid.

CMake Error at test/CMakeLists.txt:7 (BCI2000_ADD_LIBRARY_TEST):Unknown CMake command "BCI2000_ADD_LIBRARY_TEST".

CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.1) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!

I tried to remove them from linker dependencies but got lot of 'undefined' errors after building the project.

Can anyone please explain how to generate these lib files?

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Missing LIB files. BCI2000 + Visual Studio

Post by boulay » 11 Nov 2014, 12:21

I'm not going to address your issues specifically, rather I think you should revert your src tree back to its original state and take a different approach.

If you selected to build certain tools, then you should have a NewBCI2000Module.exe in your build directory.
Follow these instructions for making a new source module.

This should place a new folder in your BCI2000/src/custom folder and it will also update the CMakeLists.txt file in that folder.

Go into your custom module's folder and edit its CMakeLists.txt. Beyond the basic SRC_PROJECT and HDR_PROJECT, you'll also have to specify your hardware's include directories and library directories. To know how to do this, take a look at some of the other source modules as examples.

Then MAKE again.
Then open the VS sln and find your new module and code away.

I've included my CMakeLists.txt for a libusb device. There are probably some inefficiencies, but it works.

Code: Select all

###########################################################################
## $Id:  $
## Authors: Chadwick Boulay (chadwick.boulay@gmail.com)
## Date: 2014-03-12
## Description: Build information for the MCClibusbSource source module
##              
###########################################################################

# Set the executable name
SET( EXECUTABLE_NAME MCClibusbSource )

# Set the project specific sources
SET( SRC_PROJECT
  MCClibusbADC.cpp
  mccdevice.cpp
)

SET( HDR_PROJECT
  # perhaps you will need to add the manufacturer's SDK headers here...
  MCClibusbADC.h
  mccdevice.h
)


INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/lib/include)

IF ( WIN32 )
	LINK_DIRECTORIES(
	  ${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/MS32/dll
	)
	set(LIBUSB_1_LIBRARIES libusb-1.0)
ELSE ( WIN32 )
	set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/lib/)
	FIND_PACKAGE(libusb-1.0)
ENDIF ( WIN32 )

# Use the BCI2000_INCLUDE macro if you need to link with frameworks from /src/extlib:
# BCI2000_INCLUDE( "MATH" )
# BCI2000_INCLUDE( "SOURCEFILTER" )

# Add the source module to the Makefile or compiler project file:
LIST( APPEND SRC_PROJECT ${BCI2000_SRC_DIR}/shared/modules/CoreMain.cpp )
BCI2000_ADD_SIGNAL_SOURCE_MODULE( 
  "${EXECUTABLE_NAME}" 
  "${SRC_PROJECT}" "${HDR_PROJECT}" 
)

# finally, specify any third-party libraries that need to be linked:
# 
# TARGET_LINK_LIBRARIES( ${EXECUTABLE_NAME} TheManufacturersSDK )
TARGET_LINK_LIBRARIES( ${EXECUTABLE_NAME} ${LIBUSB_1_LIBRARIES} ) #Do I need the extension? If so, then platform specific.

IF ( WIN32 )
ADD_CUSTOM_COMMAND(
  TARGET "${EXECUTABLE_NAME}"
  POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/MS32/dll/libusb-1.0.dll" "${BCI2000_ROOT_DIR}/prog"
)
ENDIF ( WIN32 )

skvpe
Posts: 9
Joined: 13 May 2014, 10:30

Re: Missing LIB files. BCI2000 + Visual Studio

Post by skvpe » 12 Nov 2014, 18:40

Hello,

Thanks a lot for your reply. I did try as you recommended. But build fails due to those missing lib files. I will try installing latest version again..

Thanks for libusb code!

skvpe
Posts: 9
Joined: 13 May 2014, 10:30

Re: Missing LIB files. BCI2000 + Visual Studio

Post by skvpe » 18 Nov 2014, 00:51

Hi bouley,

The problem was cmake put these lib files in src->build->CmakeFiles->Frameworks folder whereas the compiler was accessing src->build->cmake->frameworks folder. So I had to copy files to this folder to remove the error.

Currently when I run this code as signal source, I get another error after doing 'Set Config' in BCI2000.

exe files-> Operator-><above code>->Dummysignalprocessing->Dummyapplication

Error->DataIOFilter::Initialize: CyAPIADC::Initialize: Parameter "SamplingRate" was accessed during initialization or processing, but not checked for consistency during preflight phase.

Files->CyAPIADC.cpp and CyAPI.cpp (driver USB file). Headers->CyUSB headers and CyAPI.h

Related code:

Code: Select all

[b]CyAPIADC.cpp[/b]
CyAPIADC::CyAPIADC(): mSourceCh( 0 ),mSampleBlockSize( 0 ),mSamplingRate( 1 )//initial values
{
  BEGIN_PARAMETER_DEFINITIONS
	"Source:Signal%20Properties int SourceCh= 8 " "8 1 % // number of digitized and stored channels",
	"Source:Signal%20Properties int SampleBlockSize= 64 " "64 1 % // number of samples transmitted at a time",
	"Source:Signal%20Properties int SamplingRate= 8000Hz " "8000Hz 1 % // sample rate",
	"Source:Signal%20Properties floatlist SourceChOffset= 8 0 0 0 0 0 0 0 0 " "0 % % // SourceChOffset",
	"Source:Signal%20Properties floatlist SourceChGain= 8 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 " "0.3 % % // SourceChGain",
  END_PARAMETER_DEFINITIONS
USBDevice = new CCyUSBDevice(NULL,GUID_KNJN_FX2);// Create an instance of the CCyUSBDevice class //
}

void CyAPIADC::Preflight( const SignalProperties&,SignalProperties& outputProperties ) const
{
  outputProperties = SignalProperties( Parameter( "SourceCh" ),Parameter( "SampleBlockSize" ),SignalType::int16 );
}

void CyAPIADC::Initialize( const SignalProperties&, const SignalProperties& )
{
	mSourceCh = Parameter( "SourceCh" );
	mSampleBlockSize = Parameter( "SampleBlockSize" );
	mSamplingRate = Parameter( "SamplingRate" );
	USBDevice = new CCyUSBDevice(NULL,GUID_KNJN_FX2);
	int devices = USBDevice->DeviceCount();
	USHORT vID, pID;
	int d = 0;
	do{
		USBDevice->Open(d); // Open USB and Close( ) if needed
		vID = USBDevice->VendorID;pID = USBDevice->ProductID;
		d++;
	} while ((d < devices ) && ((vID != 0x04B4) || (pID != 0x8613)));
	isLoaded = TRUE;
//memory allocation part
..
}

[b]CyAPI.h file[/b]
class CyAPIADC : public GenericADC
{
public: CyAPIADC();
virtual ~CyAPIADC();
virtual void Preflight( const SignalProperties&, SignalProperties& ) const;
virtual void Initialize( const SignalProperties&, const SignalProperties& );
virtual void Process( const GenericSignal&, GenericSignal& );
virtual void Halt();
PrecisionTime   mLasttime;
CCyUSBDevice *USBDevice;        

private: int mSourceCh,mSampleBlockSize,mSamplingRate;
// Some more Variables 
..
};
Any idea regarding this error?

Thanks,
skvpe

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Missing LIB files. BCI2000 + Visual Studio

Post by boulay » 18 Nov 2014, 08:15

Try adding this line in Preflight:

Code: Select all

mSamplingRate = Parameter( "SamplingRate" );

skvpe
Posts: 9
Joined: 13 May 2014, 10:30

Re: Missing LIB files. BCI2000 + Visual Studio

Post by skvpe » 18 Nov 2014, 21:51

That solved the issue. I just had to remove 'const' from declaration of preflight in few header files to make that work.

Thanks!

Locked

Who is online

Users browsing this forum: No registered users and 0 guests