Unable to compile under the eclipse/code composer studio - c

Im trying to compile the next code
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sysctl.h>
#include <sysctl.c>
#include <inc/hw_ints.h>
#include <tm4c1294ncpdt.h>
uint32_t i,CTA;
void main(void){
SYSCTL_RCGCGPIO_R=0X1008;
i=SYSCTL_RCGCGPIO_R;
GPIO_PORTD_AHB_DIR_R=0X01;
GPIO_PORTD_AHB_DEN_R=0X03;
NVIC_EN0_R=0X08;
GPIO_PORTD_AHB_IM_R |=0X02;
GPIO_PORTD_AHB_IS_R =0X00;
GPIO_PORTD_AHB_IEV_R |=0X02;
GPIO_PORTD_AHB_ICR_R |=0X02;
GPIO_PORTN_DIR_R =0X03;
GPIO_PORTN_DEN_R =0X03;
GPIO_PORTD_AHB_DATA_R =0X00;
while (1)
{
CTA=0;
GPIO_PORTN_DATA_R ^=0X01;
SysCtlDelay(2666666);
GPIO_PORTD_AHB_DATA_R |=0X01;
SysCtlDelay(100);
GPIO_PORTD_AHB_DATA_R &=~0X01;
}
}
int ECHO_ISR(void){
while (((GPIO_PORTD_AHB_DATA_R & 0X02)== 0X02)& (CTA<0XFFF))
{
CTA++;
}
GPIO_PORTD_AHB_ICR_R |=0X02;
return 0;
}
It is a little sonar using the HC-SR04 module the code composer shows the next output
Compilation failure
subdir_rules.mk:7: recipe for target 'main.obj' failed
Command-line error #1965: cannot open source file "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/"
1 catastrophic error detected in the compilation of "../main.c".
Compilation terminated.
gmake: *** [main.obj] Error 1
Command-line error #1965: cannot open source file "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/"
1 catastrophic error detected in the compilation of "../tm4c1294ncpdt_startup_ccs.c".
Compilation terminated.
gmake: *** [tm4c1294ncpdt_startup_ccs.obj] Error 1
Building file: "../tm4c1294ncpdt_startup_ccs.c"
Invoking: ARM Compiler
"/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="/home/user/workspace_v8/5" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178/inc" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178/driverlib" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/bin" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/lib" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include" --preinclude="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="tm4c1294ncpdt_startup_ccs.d_raw" "../tm4c1294ncpdt_startup_ccs.c"
>> Compilation failure
subdir_rules.mk:7: recipe for target 'tm4c1294ncpdt_startup_ccs.obj' failed
gmake: Target 'all' not remade because of errors.
**** Build Finished ****
It shows a Error 1, but no more details. The includes are the /inc and /driverlib besides the system added alone.
It says it cant open the /home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/ but Its already added to the project
Update
After removing the preinclude it now throws more errors

Remove "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/" from the preinclude section

Related

Linux RT-Unable to link .lib to VSCode-Undefined reference to `DAQmxCreateTask'

I was trying to cross compile a C code with CMake inside Linux RT using VSCode. But I am encountering an error due to the mistake in linking (.so) file with project. I have gone through many solutions but failed to run the task. My code is given below:
#include<stdio.h>
#include"/home/admin/helloworld/src/NIDAQmx.h"
TaskHandle taskHandle=0;
int ret=0;
void main()
{
printf("Hello world");
ret=DAQmxCreateTask("task",&taskHandle);
printf("Return for creating task is %d\n",ret);
DAQmxStopTask (taskHandle);
DAQmxClearTask(taskHandle);
printf("Task closed ");
}
Error while running the task.
[ 50%] Linking C executable bin/helloWorld
CMakeFiles/helloWorld.dir/home/admin/helloworld/src/helloWorld.c.o:
In function `main':/home/admin/helloworld/src/helloWorld.c:11: undefined reference to `DAQmxCreateTask'
/home/admin/helloworld/src/helloWorld.c:13: undefined reference to `DAQmxStopTask'
/home/admin/helloworld/src/helloWorld.c:14: undefined reference to `DAQmxClearTask'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/helloWorld.dir/build.make:95: bin/helloWorld] Error 1
make[1]: *** [CMakeFiles/Makefile2:68:CMakeFiles/helloWorld.dir/all] Error 2
* The terminal process
"/bin/bash '-c', 'make'" failed to launch
(exit code: 2).
* Terminal will be reused by tasks, press any key to close it.
I modified my CMakeLists.txt as follows:
cmake_minimum_required(VERSION 3.7.2)
# project settings
project(helloWorld VERSION 0.1.0)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
set(CMAKE_GENERATOR "Unix Makefiles")
# executable settings
add_executable(helloWorld ../src/helloWorld.c)
set(CMAKE_BUILD_TYPE Debug)
LINK_LIBRARIES(NIDAQmx ../src/libnidaqmx.so)
If I remove the elements associated with NIDAQmx code working properly.

Why does a function declared and included using header file show as undefined?

I have the following code in my files and all of these are in the same directory:
readMake.c:
#include <stdio.h>
#include "my_make.h"
int main(int argc, char* argv[]) {
printSomething();
}
printer.c:
#include <stdio.h>
int printSomething(){
printf("printed\n");
return 1;
}
my_make.h:
int printSomething();
However, when I try to compile and run my code, I get the following error:
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: CMakeFiles/prob1.dir/readMake.c.o: in function `main':
/cygdrive/c/Users/harsh/OneDrive/Documents/CSC352/assg9/prob1/readMake.c:5: undefined reference to `printSomething'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/prob1.dir/build.make:93: prob1.exe] Error 1
make[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/prob1.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/prob1.dir/rule] Error 2
make: *** [Makefile:124: prob1] Error 2
My IDE shows the proper signature of the printSignature function and where it is declared in the header file when I hover over the call in main, but the compilation doesn't seem to be working. Why is this happening and how can I resolve this?
I figured out a solution specific to CLion, unloading the CMakeLists.txt file and then creating a new one seems to resolve the issue.
I had to do 'Tools>CMake>Unload'
and then create a new CMakeLists.txt file which was automatically done by clicking an option appearing at the top of the window and selecting all of the files from a list of checkboxes.

why cannot open source input file "ARMCM3.h":? with ST-link and STM32F103ZET6

When I tried to build the following project with those code, the error happened like this !
#include <stm32f10x.h>
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
void LED_GPIO_Config(void){
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB, GPIO_Pin_5);
}
//delay
void delay_nms(u16 time){
u16 i = 0;
while(time--){
i = 12000;
while(i--);
}
}
//main
int main(void){
SystemInit();
LED_GPIO_Config();
while(1){
GPIO_SetBits(GPIOB, GPIO_Pin_5);
delay_nms(1000);
GPIO_ResetBits(GPIOB, GPIO_Pin_5);
delay_nms(1000);
}
}
The output like this:
*** Using Compiler 'V5.06 update 2 (build 183)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
compiling ControllerFunctions.c...
compiling BayesFunctions.c...
compiling FastMathFunctions.c...
compiling DistanceFunctions.c...
compiling ComplexMathFunctions.c...
compiling BasicMathFunctions.c...
compiling main.c...
compiling LED_MCBSTM32E.c...
compiling MatrixFunctions.c...
assembling irq_cm3.s...
compiling cmsis_os1.c...
compiling SVMFunctions.c...
compiling StatisticsFunctions.c...
compiling SupportFunctions.c...
compiling rtx_lib.c...
compiling rtx_evr.c...
compiling rtx_delay.c...
compiling rtx_evflags.c...
compiling rtx_kernel.c...
compiling CommonTables.c...
compiling rtx_memory.c...
compiling rtx_mempool.c...
compiling rtx_mutex.c...
compiling rtx_semaphore.c...
compiling rtx_system.c...
compiling rtx_msgqueue.c...
compiling RTX_Config.c...
compiling RV_Framework.c...
D:\u_version projects\ZET6\LED_1\RTE\CMSIS_RTOS_Validation\RV_Config.h(10): error: #5: cannot open
source input file "ARMCM3.h": No such file or directory
#include "ARMCM3.h"
C:\Keil_v5\ARM\PACK\ARM\CMSIS-RTOS_Validation\1.1.0\Source\RV_Framework.c: 0 warnings, 1 error
compiling RV_Report.c...
D:\u_version projects\ZET6\LED_1\RTE\CMSIS_RTOS_Validation\RV_Config.h(10): error: #5: cannot open
source input file "ARMCM3.h": No such file or directory
#include "ARMCM3.h"
C:\Keil_v5\ARM\PACK\ARM\CMSIS-RTOS_Validation\1.1.0\Source\RV_Report.c: 0 warnings, 1 error
compiling RV_Timer.c...
D :\u_version projects\ZET6\LED_1\RTE\CMSIS_RTOS_Validation\RV_Config.h(10): error: #5: cannot open
source input file "ARMCM3.h": No such file or directory
#include "ARMCM3.h"
C:\Keil_v5\ARM\PACK\ARM\CMSIS-RTOS_Validation\1.1.0\Source\RV_Timer.c: 0 warnings, 1 error
compiling RV_WaitFunc.c...
D:\u_version projects\ZET6\LED_1\RTE\CMSIS_RTOS_Validation\RV_Config.h(10): error: #5: cannot open
source input file "ARMCM3.h": No such file or directory
#include "ARMCM3.h"
C:\Keil_v5\ARM\PACK\ARM\CMSIS-RTOS_Validation\1.1.0\Source\RV_WaitFunc.c: 0 warnings, 1 error
compiling cmsis_rv.c...
D:\u_version projects\ZET6\LED_1\RTE\CMSIS_RTOS_Validation\RV_Config.h(10): error: #5: cannot open
source input file "ARMCM3.h": No such file or directory
#include "ARMCM3.h"
C:\Keil_v5\ARM\PACK\ARM\CMSIS-RTOS_Validation\1.1.0\Source\cmsis_rv.c: 0 warnings, 1 error
compiling rtx_timer.c...
compiling rtx_thread.c...
compiling os_systick.c...
assembling startup_stm32f10x_hd.s...
compiling FilteringFunctions.c...
compiling TransformFunctions.c...
compiling misc.c...
compiling stm32f10x_gpio.c...
compiling DMA_STM32F10x.c...
compiling stm32f10x_rcc.c...
compiling GPIO_STM32F10x.c...
compiling system_stm32f10x.c...
".\Objects\LED.axf" - 5 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:05
Load "D:\\u_version projects\\ZET6\\LED_1\\Objects\\LED.axf"
_____^
*** error 56: cannot open file
Error: Flash Download failed - Could not load file 'D:\u_version
projects\ZET6\LED_1\Objects\LED.axf'
Flash Load finished at 11:00:32
Besides, I am using st-link with stm32f103zet6!
I do not know why it ccould not find the file and I also did not find the file either!
Is that because some packages were broken or how to solve this?
Thank you!
Probably you miss a define needed to import the right headers. Try to pass STM32F103xE symbol to the compiler. The file may be not located in the project folder but could be imported from an another include path outside the project.

Unable to compile a C file in Contiki

I am trying to write a code in contiki that allows motes to randomly generate values.
Below is the code I tried:
#include "contiki.h"
#include "stdio.h" /* For printf() */
#include "stdlib.h"
PROCESS(random_process, "Random process");
AUTOSTART_PROCESSES(&random_process);
PROCESS_THREAD(random_process, ev, data)
{
PROCESS_BEGIN();
int r=rand();
printf("Hello, world. Random Number is %d",r);
PROCESS_END();
}
While generating the makefile I get the below error:
user#instant-contiki:~/Desktop/Random$ make target=native random_sample
TARGET not defined, using target 'native'
CC random_sample.c
LD random_sample.native
contiki-native.a(broadcast-annou): In function `set_timers':
/home/user/contiki-2.7/core/net/rime/broadcast-announcement.c:171: undefined reference to `random_rand'
collect2: ld returned 1 exit status
make: *** [random_sample.native] Error 1
rm random_sample.co
Can someone please help me with this? Thanks in advance.
You have not configured your project properly, you have to setup Makefile and project-conf.h to start with contiki, read the following hello-world example: http://github.com/contiki-os/contiki/tree/master/examples/hello-world.
I recommend you use the example in the link as a project start files.

C - Unable to get shmget/shmat to compile

I'm pulling out my hair trying to figure out why this isn't working on my Minix system.
When I try to compile my C program, I get the following error:
#make
link pm/pm
program.o: In function `do_function':
program.c:(.text+0x1e): undefined reference to `shmget'
program.c:(.text+0x36): undefined reference to `shmat'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1
Stop.
make: stopped in /usr/src/servers/pm
#
This is my code:
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/stat.h>
/* Some other includes here */
typedef struct {
//struct elemLi *next;
//elem sem;
int ref_count;
} elemLi;
int do_function(void){
int segment_id; //Shared Memory ID
struct elemLi* sli; //Shared Memory Pointer
segment_id = shmget(IPC_PRIVATE, sizeof(elemLi),0660 | IPC_CREAT);
sli = (struct elemLi *)shmat(segment_id,NULL,0);
return -1;
}
As you can see, I've included the proper header files for these calls and it's still saying the references are undefined. I was able to successfully use this in another program, so I've completely run out of ideas as to why this isn't working in this instance.
Edit: This is within a system call. I assume that doesn't make a difference.
Thanks for the help everyone, it looks like it was a missing library in the linker. I added libc, using -lc, to the Makefile, and now it seems to be compiling fine.

Resources