MSP430 (msp430-gcc) linker undefined reference to - c

I'm trying to compile my MSP430 project using the Linux msp430-gcc compiler.
When I try to compile it using the CCS IDE it works just fine, but when I try to compile it using the msp430-gcc commandline tool, I get linker errors about functions like calloc and __no_operation.
The beginning of my source file looks like this:
#include <stdio.h>
#include <stdlib.h>
I compile the program using the following command:
msp430-gcc -mmcu=msp430g2553 -o test.out source_file.c
So it looks like I include the stdio.h and stdlib.h just fine, but I still get linker errors about functions like calloc.
I also tried using arguments like -lc, but that doesn't seem to help.
I read that both stdio and stdlib get included automatically by the compiler so I guess there is no need to use additional arguments for these files.
Does anyone have any idea how I could fix this?
Thanks.

mspgcc was a fork of gcc; by now, it's horribly outdated.
Nowadays, MSP430 development happens in gcc itself.
You could compile the latest version of gcc yourself, or hope that your distribution has a MSP430 cross compiler, or get it from TI.

Related

difference of compiler between macOS and linux?

I am now learning c language, and my school put all assignments on myth, every time we have to log in by ssh and execute command remotely.
Thus I want to download the files and execute them on my own macbook. However when I use make command to compile the files, I got errors and warnings such as :
gcc -g -O0 -std=gnu99 -Wall $warnflags -m32 -c -I. vectest.c -o vectest.o
warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'?
vectest.c:10:10: fatal error: 'error.h' file not found
#include <error.h>”
I googled these problems but could not find a satisfactory answer. can anyone help me solve this ? or I have to use a linux machine instead?
Indeed; compilers for various platforms (even if it's the "same" compiler, such as GCC) may have different flags and behaviors. You may be able to get it to work - you could remove the -Wlogical-op flag from $warnflags in your Makefile, but if the error.h file is a system-supplied header file, you're probably in trouble. Therefore, I suggest that you download e.g. VirtualBox and run Linux on it.
See error(3) for what this header provides. It's not specific to linux but to the GNU C library. What you COULD do is provide your own minimal implementation of these functions and write your own error.h.
You could even `#define' them to do nothing at all, but then you will probably lose some error reporting in the existing code. Maybe you could try to find a teacher understanding the problem and discuss the issue ... it's probably better to learn standard C not using any platform-specific extensions.

gcc iostream not found in Ubuntu 13.10

I have a fresh install of Ubuntu 13.10 here for a class, and I have to write a pretty simple program just to prove that we remember things from basic programming. It just has to be a tic tac toe game, basically.
Now that's all well and good but every time I've tried to compile it, it says it can't find iostream. (error message below)
cameron#ubuntu:~/Documents/ECE 2220$ gcc -Wall prog1.c
prog1.c:1:20: fatal error: iostream: No such file or directory
#include <iostream>
^
compilation terminated.
Now, maybe I have to use g++, but that compiles it as c++, right? Which doesn't work at all for my purposes, since it's for a class in c. I have installed build-essential, and thought that that could be the issue, but after a reinstall, it has the same issue. I can't find anything else quite like this. Does anyone have any idea how to fix the issue?
You should compile with g++. gcc invokes C compiler.
And consider giving another extension to your source file. C++ source files usually have extension .cc, .cpp or .C (capital).
And yes, you have to compile it as C++. You cannot use classes and <iostream> in C.

How to fix C program error for Openmpi with netbeans running on ubuntu 12.04

I am trying to run a MPI program with C language.
I have installed GCC compiler and the openmpi libraries. I am running ubuntu Linux and Netbeans IDE. My challenge is that after including ‘mpi.h’ in my header file and compiling the application, I still get ‘fatal error : cannot find file mpi.c’. I have the files in home/user/lib/openmpi/include, but I cant get it too work.
Can anyone help?
You could try to change the compiler to /path/mpicc and the debugger to mpirun. This should work, although I did not test it, but probably the best way to compile MPI code is via terminal.
If you really depend on the IDE you cound try writing your code with it (to take advantage of auto-completion and such) and compile it in terminal using mpicc -o main.exe main.cpp [other .cpp files] and run it with mpirun -np number_of_processes_to_use ./main.exe [args]. You could write a small script or a Makefile to do it all in one command.
Good luck!
to save yourself some sanity, I'd recommend opening up a terminal and going from there (at least until you figure out what's what).
Also, using the mpi compiler to do things would simplify your life. (and likely automatically solve the missing source issue, as it should know where they are by default).
If you still can't locate them during compile then I'd look at adding the location where mpi.c & mpi.h are located to your C Include Path: How to add a default include path for gcc in linux?

Linking gfortran libraries to c++ program in CodeBlocks under Ubuntu

I have an Ubuntu under Vmware, and use Code::Blocks, as I am not a very powerful command line user
and prefer IDE to Vim+console.
I am trying to compile a program which uses a c++ wrapper to fortran library.
However compiling gives me the following errors:
undefined reference to `_gfortran_compare_string'
There are a lot of errors of this type and a bunch of other similar to this one.
I have gfortran 4.6.3. I found searching that it is probably a linking problem, and people say to
use -lgfortran option for linker. When I add this to linker options in the Code::Blocks it does not change anything, errors continue. So, here are some question:
Is this a correct option for linker?
May be I have to give linker a direct path to the fortran library?
How do I find where are the fortran libraries installed? (I don't know a lot about linux ((( )
What am I doing wrong and how to fix it.
Have you added gfortran as a library to linked to your project or lgfortran? The l is just an option for the g++ for linking the library gfortran to your code. I am not familar with Code::Blocks but you should look for a place where you can enter libraries you want to use and add the gfortran directly.
My guess is that the Code::Blocks side can help you to find this place.
Kim Kulling
My guess is something like /bin/lib /usr/lib or /usr/local/lib. Just take a look into your filesystem. Unfortunately I do not have a Linuix at work. Maybe someone else?
Kim Kulling

Problem to compile a C-program by GCC in the latest Cygwin due to tgmath.h and complex.h

I have successfully compiled a C-program with GCC in Mac OS X and Linux, but have got the following error message in Cygwin 1.7.5:
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/tgmath.h:38:21: error: complex.h: No
such file or directory
I have noticed that several guys reported that tgmath.h has problems in Cygwin. However, due to the lack of knowledge I cannot understand if those issues have been already fixed or if they are related to the error I get. See, for example:
http://cygwin.com/ml/libc-alpha/1999-12/msg00021.html
http://cygwin.com/ml/libc-hacker/2007-07/msg00012.html
As an experiment, my colleagues have replaced include <tgmath.h> with include <math.h>. However, the code threw an exception.
Could you explain me what can be wrong in Cygwin's tgmath.h or complex.h, and how I can get through it?
This could completely wrong, but make sure you're compiling with -std=c99, complex.h is part of the C99 standard.
Unfortunately the complex.h stuff hasn't been implemented for Cygwin (or more precisely, for newlib, which is the C library used by Cygwin).
http://cygwin.com/cygwin-api/std-notimpl.html

Resources