cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
BNicola
Visitor
Visitor
491 Views
Registered: ‎08-22-2020

Can't build a C++ application with XRFdc

Hi There,

I am using teh RFSoC evaluation board ZCU111.

I recently built an example application (copied it from the rfdc-data-write-example ready available under the project-spec/meta-user/recipes-apps).

I was successfully able to build my own application in C that can access the DACs straight away.

Now I want to immigrate to C++ projects, I used the petalinux-create command to create a C++ template project.

Now when I imported all the C files (data_interface.c, clock_interface.c,......)from the example project and tried to use them in the same way I used it in  my C project it then couldn't build the project.

 

Here is a snippet of my C++ main.cpp

 

#include <iostream>
#include <netdb.h> 
#include <netinet/in.h> 
#include <string.h> 
#include <arpa/inet.h>
#include <math.h>
#include <stdio.h> 
#include <stdlib.h> 
#include "xrfdc.h"
#include "rfdc_interface.h"
#include "data_interface.h"
#include "clock_interface.h"
#include "rfdc_functions.h"

#define MAX_BUFF_SIZE 800000 
#define QB_PORT 8070 
#define RF_CTRL_PORT 8081
#define RF_DATA_PORT 8082 
#define RFDC_DEVICE_ID  0
using namespace std;

int main(int argc, char *argv[])
{
   int ret;

   ret = rfdc_inst_init(RFDC_DEVICE_ID);
   if(ret != XRFDC_SUCCESS) 
   {
      printf("Failed to initilize RFDC\n");
      return -1;
   }
   else
   {
      printf("===========================\n");
      printf("Initilized RFDC Successfully\n");
      printf("===========================\n");
   }

   ret = initRFclock(ZCU111, LMK04208_12M8_3072M_122M88_REVAB, DAC_245_76_MHZ, DAC_245_76_MHZ, ADC_245_76_MHZ);
   if(ret != SUCCESS)
   {
      printf("Unable to configure RF clocks\n");
      return ret;
   }
   else
   {
      printf("=================================\n");
      printf("Configured RF clocks successfully\n");
      printf("=================================\n");
   }
	/*cout << "Hello, PetaLinux World!\n";
	cout << "cmdline args:\n";
	while(argc--)
		cout << *argv++ << endl;*/

	return 0;
}

 

Here is my qbcontroller.bb file

#
# This file is the qbcontroller recipe.
#

SUMMARY = "Simple qbcontroller application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://qbcontroller.cpp \
           file://board.h \
	   file://clock_interface.c \
	   file://clock_interface.h \
	   file://common.c \
	   file://common.h \
	   file://data_interface.c \
	   file://data_interface.h \
	   file://gpio.c \
	   file://gpio.h \
	   file://rfdc_functions.c \
	   file://rfdc_functions.h \
	   file://rfdc_interface.c \
	   file://rfdc_interface.h \
           file://Makefile \
		  "

S = "${WORKDIR}"

DEPENDS = "libmetal"
DEPENDS = "rfdc"

do_compile() {
	     oe_runmake
}

do_install() {
	     install -d ${D}${bindir}
	     install -m 0755 qbcontroller ${D}${bindir}
}

 

And my Makefile

APP = qbcontroller

# Add any other object files to this list below
SRCS=$(wildcard *.cpp)
APP_OBJS = $(SRCS:.cpp=.o)

all: $(APP)

$(APP): $(APP_OBJS)
	$(CXX) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS) -lrfdc -lmetal -lm
clean:
	rm -f $(APP) *.o
0 Kudos
1 Reply
zhendon
Community Manager
Community Manager
408 Views
Registered: ‎08-30-2011

Hi @BNicola 

What error message did you get when built the project in petalinux?

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos