473,626 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compiler problem with c-code in Matlab

84 New Member
I have a Matlab code which works fine in windows. Now I installed Xubuntu (because this way I have admin rights(=root) which I don't have on windows) and want to use the same code.

To be able to use the C-code you have to compile it from Matlab comand line with the comand
Expand|Select|Wrap|Line Numbers
  1. mex myfile.c
where before with mex -setup you define which compiler to use, the only choice I had was gcc (version 4.something).

Now if I compile I get the following error:
Expand|Select|Wrap|Line Numbers
  1. >> mex givegradient.c
  2. Warning: You are using gcc version "4.1.2".  The earliest gcc version supported
  3. with mex is "3.4.0".  The latest version tested for use with mex is "3.4.5".
  4. To download a different version of gcc, visit http://gcc.gnu.org 
  5. givegradient.c:2: error: expected identifier or ‘(’ before ‘/’ token
  6. givegradient.c:16: error: expected identifier or ‘(’ before ‘/’ token
  7. givegradient.c:142: error: expected declaration specifiers or ‘...’ before ‘/’ token
  8. givegradient.c:143: error: expected declaration specifiers or ‘...’ before ‘/’ token
  9. givegradient.c:144: error: expected declaration specifiers or ‘...’ before ‘/’ token
  10. givegradient.c:147: error: conflicting types for ‘mexFunction’
  11. /usr/local/matlab/extern/include/mex.h:148: error: previous declaration of ‘mexFunction’ was here
  12. givegradient.c: In function ‘mexFunction’:
  13. givegradient.c:156: error: ‘nrhs’ undeclared (first use in this function)
  14. givegradient.c:156: error: (Each undeclared identifier is reported only once
  15. givegradient.c:156: error: for each function it appears in.)
  16. givegradient.c:159: error: ‘prhs’ undeclared (first use in this function)
  17. givegradient.c:159: warning: assignment discards qualifiers from pointer target type
  18. givegradient.c:166: error: ‘plhs’ undeclared (first use in this function)
  19.  
  20.     mex: compile of 'givegradient.c' failed.
  21.  
  22. ??? Error using ==> mex
  23. Unable to complete successfully.
  24.  
And the first lines of my code have just the usual comments, i.e.:
Expand|Select|Wrap|Line Numbers
  1. /* $Revision: 1.1 $ */
  2. // Automatically generated by Matlab AppWizard version 1.0
  3. //
  4. // This is the gateway routine for a MATLAB Math/Graphics Library-based
  5. // C MATLAB MEX File.
  6.  
  7.  
  8. #include "mex.h"
  9. #include <math.h>
  10. #define K 10.0
  11. #define MAX(A,B) ((A)>(B)?(A):(B))
  12. #define MIN(A,B) ((A)<(B)?(A):(B))
  13. #define SGN(A) ((A)>0?1.:-1.)
  14. #define ABS(A) ((A)>0?(A):-(A))
  15.  
  16. etc.
  17.  
I can post also the rest of the code if needed...

I think it must be a compiler thing because the code worked with no problems on windows...
Thanks for any help
Feb 22 '08 #1
1 4620
sanctus
84 New Member
With some help from someone at work I figures it out, in order to have it seen as a C++ file you have to name the file as *.cc or *.cpp and then it works fine....
Feb 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2025
by: Christopher M. Lusardi | last post by:
Hello, Can I run the subject line program using CC instead of cc? I attempted to use the "-c" option and it told me things were undefined. Isn't this CC option the same as the cc -c option? Thank you, Christopher Lusardi
7
3102
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I saw cuj's conformance roundup, but the result is quite old. I think many people like me want to know newer c++ standard conformance test result. Especially, I want to know the compiler conformance of vc7.1, vc8.0, gcc 4.x and intel c++, and also each implementation of STL. The world is moving on, right? :)
12
25448
by: Unbiased_me | last post by:
Hi There I recently read in book that the C compiler is written in C. I unable to comprehend the concept behind this. How is the compiler design started...Where dodoes one start. I tried Googling for the answer that C is written in C, however the web search proved futile. C # and .net is written in .net...What!, and the list goes on
1
13211
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem,
3
5261
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 535F072A): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are...
6
2722
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep facing the same problem with many of them: I keep getting errors such as: ....\WinUser.h(8028): fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701)
12
2449
by: nicdude | last post by:
There is a Comeau C++ compiler special offer at http://www.comeaucomputing.com Is it really as compliant as it seems to imply? In terms of Standard C++, what is it missing? Can it handle templates well?
0
1538
by: skip | last post by:
Here's a trivial little Python session which attempts to use compiler.walk (mostly unsuccessfully): % python Python 2.4.2 (#1, Feb 23 2006, 12:48:31) on sunos5 Type "help", "copyright", "credits" or "license" for more information. Module(None, Stmt(, Const('red')), Assign(, Const('blue'))])) <compiler.visitor.ExampleASTVisitor instance at 0x81f0eac>
30
2953
by: lovecreatesbea... | last post by:
K&R says the following in the preface to the first edition, "... the C compiler, and ... are written in C." I'm wondering, does it say even the first / original C compiler was written in C?
49
2111
by: valentin tihomirov | last post by:
fDeleted = false; uint jobId; foreach (Struct struct in structures) { if (struct.type == JOB) { jobId = struct.id; if (struct.dataType == STATUS) fDeteted = (struct.data & STATUS_DELETED) != 0; }
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.