473,230 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Compiler problem with c-code in Matlab

84
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 4561
sanctus
84
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
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? ...
7
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...
12
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...
1
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...
3
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...
6
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...
12
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...
0
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",...
30
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
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
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.