473,404 Members | 2,187 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,404 software developers and data experts.

How to compile and link several c++ files with *mex*

xz
I am programming some c++ codes to be called within Matlab.

If there is only one c++ file, life is simple. You simply mex the cpp
file (
with mexFunction(...) )and call the function within Matlab.

However, if you have several c++/h files, then what's standard
procedure to
compile and link the files?

for example, I have:

A.cpp (which contains the mexFunction and includes B.h)
B.h (contains the declarations of some data structures used in A.cpp)
B.cpp (implementation of the data structures declared in B.h)

The weird thing I found is that if you simply run:

mex B.cpp

It just compiles without complaining there is no mexFunction() or
main(),
which is not like the case if you gcc some c++ file without a main()
and
without using the option -c.

If you run

mex A.cpp

It also compiles without complaining that some function called in A
(defined
in B) has not be defined.
If you run

mex A.cpp B.cpp

you get an A.mexa64. However, when I call this A within Matlab, it
seems
like the functions defined in B and called in A are ignored without
being
called.

Anyway, I don't think I am compiling or linking in a correct way. "mex
--help" does not help very much.

Can you guys give some ideas about the compiling and linking of c++
with mex?
Mar 14 '08 #1
1 2037
xz wrote:
I am programming some c++ codes to be called within Matlab.

I[redacted]
Any specifics on compilation options, etc.. are OT.

Try comp.soft-sys.matlab
Mar 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: LP | last post by:
Hi, I have a site which runs on .Net technology. The site is already deployed and running. I need to change 1 file for some small enhancement. Please tell me, how can I compile that 1 file and...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
13
by: Martijn van den Branden | last post by:
Hi, sorry if this message gets posted twice, i seem to have some problem posting to newsgroups. i've rewritten some loop in matlab using the mex interface method in c, and i've achieved a...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
2
by: MB | last post by:
Hello! At home I am using ASP.net to develop an asp application. Now I have copied this application to my IIS5.0 server at my workplace. Everything works fine, but then I would do a change in a...
30
by: David T. Ashley | last post by:
I have a large project on a Linux box that may eventually have several hundred 'C' source files, which need to be compiled and linked into several executables. Not all of the executables will...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
9
by: beet | last post by:
Hi, I am really not good at c/c++. Some simple code.. #include <stdio.h> #include <stdlib.h> #include <math.h> #include "simlibdefs.h"
0
by: =?Utf-8?B?a2F1c2hhcw==?= | last post by:
Apologies for cross posting to couple of WCF related forums, but I am frantically trying to find a solution to this WCF Mex endpoint problem described below: I am getting this weird error when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...

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.