Undefined function for input arguments of type 'double' [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I downloaded the MATLAB code from here http://cazencott.info/dotclear/public/code/scones.zip. When I run 'demo', it says "Undefined function 'maxflowmex' for input arguments of type 'double'". In fact there is only a c++ file "maxflowmex.cpp" in the folder (already added to path). Whether it needs a "maxflowmex.m" instead of "maxflowmex.cpp" to run properly? Or some other methods to call "maxflowmex.cpp"? Or I need to compile something?

I just took a look at the zip file. There are MEX wrappers in the maxflow directory that are written where MATLAB calls these functions which are written in C, but are runnable in MATLAB. These MEX wrappers need to be compiled using a compiler that is compatible for your operating system before you run them.
However, there are pre-compiled binaries, but I only see 64-bit binaries for Linux and Mac OS and I don't see Windows binaries. Because you can't run them, you are most likely running a 32-bit operating system or Windows. I suspect you are running either Windows or 32-bit Linux, as Mac OS by default ships out as 64-bit.
There is a make.m script that you need to run so that you can compile the maxflow library for your machine. Once you compile the library, running demo.m should be successful.
Before you do that, you need to make sure you set up mex by doing mex -setup in the command window, then choose the right compiler. Once you do this, run make.m that's inside the maxflow directory.
If you don't have a compiler, if you're using Linux, doing an apt-get on the gcc packages should be good enough, so:
sudo apt-get update
sudo apt-get install gcc-4.6-base g++-4.6 cpp-4.6 libgomp1 libquadmath0 libc6-dev
If you are using Windows, then the supported compiler that you need will depend on what version of MATLAB you are using. I'm assuming you are using the latest one, and so downloading the latest version of Visual Studio Express as well as the SDK should be sufficient.
http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=40758

Related

What is an easy way to install a unix terminal with a C++ mingw compiler?

I'm going to teach students to use SFML with C++, and I'm afraid the school doesn't have visual studio C++ installed, or will be a bit heavy to use for those students.
I want to have a plan B and have the option of a simple makefile that I can build on windows with SFML.
https://www.sfml-dev.org/download/sfml/2.5.1/ this page offers binaries compiled with different, specific versions of mingw with their respective mingw package links, unfortunately mingw doesn't include an unix terminal, like the one included with git-bash, so I can run a makefile.
What are the steps required to have a problem unix terminal, running in windows, minsys, msys2 or not, that can work well with those mingw packages? I have trouble finding help or proper instructions.
You want https://www.msys2.org/
It provides bash terminal and already contains mingw compiler. Perhaps it even has SFML packages already.

Difference between the windows installation of minGW64 and the MSYS2 shell installed version of minGW64

I have been using the minGW64 compiler with Visual studio code on windows for some time. However, there are certain limitations to it when it comes to certain libraries. The absence of a make tool and the inability to execute a config script while compiling a c++ program being the main ones. I came to know of MSYS, a tool provides a UNIX environment that allows us to do certain things that are forbidden by the windows terminal. I installed it but I saw that I need to install mingw64 again, from within the terminal to use it with MSYS2.
My question is, is there no way I can use my earlier mingw copy with this installation of MSYS2? Is there some difference between the mingw64 that comes with MSYS2 and the standard installation?

How to statically compile a Fortran code

I compiled a copy of codes on one PC by Intel Fortran with the Lapack library. And then I ran it on another PC (the same OS without having Lapack installed). It failed.
This can be solved by installing Lapack on the other PC. The same problem occurs when using other libraries. This looks like a dynamical compiling issue (I am not sure). My question is how to get a real executable file that can be run on any machine?
I get a quite clear answer now. The direct answer to the question is (as #Vladimir F mentioned & #Ross) use option "-static" for both gfortran and ifort.
Some possibly occurred problems.
The libs for static compiling and dynamical compiling are different. For instance, we may have installed a lib called "LIBNAME" already. However, a similar lib called "LIBNAME-static" may be needed for the "-static" option version. According to the warning of something like:
/usr/bin/ld: cannot find -lLIBNAME
what we need to installed is libLIBNAME. We can install it (Fedora for instance) by
sudo dnf install libLIBNAME.
And
sudo dnf install libLIBNAME-static
may also needed. Just try them.

install multiple versions of g++(or gcc) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was wondering if it is possible to install multiple versions of g++ on the same machine without any problem.
I use the almost current gcc for my work(4.6.1). Now for my studies, my teacher has given us an incomplete project to complete and he says we should install gcc 3.4.3 .
please note that I have already read this : Is it possible to install 2 different versions of GCC at the same time? but I don't know what PATH I should set.
Moreover, I would like to use eclipse for both version. So I may need some guidance for that settings too.
Thank you very much
In bash you could do two scripts like this:
first one:
export PATH=/path/to/your/3.4.3/bin:$PATH
eclipse&
and
export PATH=/path/to/your/4.6.1/bin:$PATH
eclipse&
By running one of those, eclipse should use first gcc it finds in your path. Also your default gcc should still be primary, if you don't run any scripts.
BTW:
You can probably strike a deal with your professor on what c++ standard he wants you to use (and what libraries), not what outdated version of compiler you should use to compile your code.
If you are using some Linux distribution, you can install several versions of GCC; for instance on Debian or Ubuntu you could install both gcc-4.6 and gcc-4.7 (the exact versions available depend upon the actual distribution).
Notice that GCC 3.4.3 is a very ancient version of the compiler (it has been released in november 2004). You may have trouble to install such an ancient version of GCC on your machine. Notice also that recent GCC (last version is 4.7) gives much better warnings, optimizations, and standard conformance than ancient version.
Of course, you don't need eclipse to use GCC. You could use some plain editor like gedit or emacs, and compile either on a command line (if you have only one file) or using a builder like make.
I would not bother installing GCC 3.4.3 on a recent machine (i.e. any Linux distribution from the last few years), because you could spend more than a week in installing such an old thing, and still fail. I would use the latest GCC available on that machine, always compile with -Wall -g and ask (or tell) my teacher about it.
Learn also to use the gdb debugger, and some version control like git.
The hints I gave here are probably relevant to you.

C++ cross-compiler from Windows to Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Are there any user friendly tools out there to cross-compile from Windows to Linux?
crosstool-ng supports building cross-compilers with cygwin host.
Overview:
Install cygwin, with development packages
Download crosstool-ng
Extract the tarball (tar xvjf crosstool-ng*)
Run ./configure
When configure complains about a missing tool, go back to cygwin setup and install the corresponding package (e.g. flex, libtool, ncurses-devel) You'll need at least the following:
Devel/gperf
Devel/bison
Devel/byacc
Devel/wget
Devel/patch
Devel/make (GNU version)
Devel/automake 1.10+
Libs/libncursesw10
Libs/libncursesw10-devel
make
make install
Create a new directory for building the cross-compiler, e.g. /usr/src/cross-linux-gnu-root
Enable system-wide case sensitivity support in the registry (see https://superuser.com/questions/266110/how-do-you-make-windows-7-fully-case-sensitive-with-respect-to-the-filesystem#answer-842670)
Mount the directory case-sensitive (e.g. mount c:/cygwin/usr/src/cross-linux-gnu-root /usr/src/cross-linux-gnu -o binary,posix=1)
From inside the cross-compiler build directory, ct-ng menuconfig
In the menus, set target architecture to x86 (probably) and subarchitecture to i686 (avoids GCC 4.8 issues, thanks osm0sis), target kernel to linux, and target C library to glibc, and enable the C++ compiler.
To work around make 4.0 issues, also enable EXPERIMENTAL in Paths and misc options then, go in Companion tools (at top-level) and enable Build some companion tools and then make 3.81 (Thanks osm0sis)
wget has issues with the latest kernel.org certificates so use the .wgetrc method in this accepted answer: How do I fix certificate errors when running wget on an HTTPS URL in Cygwin? (Thanks osm0sis)
Currently 3 file patches are required to avoid further errors:
the _libintl_gettext error as mentioned in the comments
the byteshift headers, and
the ELF headers (Thanks Duncan Calvert & osm0sis)
ct-ng build
Of course, this is NOT going to enable you to build linux applications from inside Visual Studio. (VS2010 and later let you build with other toolchains such as gcc, but you'd need an appropriate toolchain description in addition to the cross-compiler built by crosstool-ng). But you'll have a working g++-linux-gnu, which you can either run directly or using a Makefile.
NOTE: Building the cross-compiler takes a LONG time. osm0sis has provided a prebuilt gcc 4.8.1 here, along with his notes on building the cross-compiler (used to update this answer).
Your best bet is to use a cross platform IDE like Code::Blocks that can import MSVC projects, and generate a Makefile for Linux, which you can then run on a Linux (with even the same program if you so wish).
So your work flow would then look something like the following:
Code, Compile, and debug on MSVC -> import into Code::Blocks & generate Makefile
-> test compile and debug with GCC
-> copy to Linux with Code::Blocks -> test compile & debug on Linux
It's a little obtuse, probably, but at least Code::Blocks takes care of a lot of those small details with things like Makefiles, and what not.
Compile to Linux from Windows without to use virtualization or cross compiler but only natively via CoLinux. Create native Linux executable files without leave (reboot) windows. C/C++ Compiling for Linux under Windows through Cooperative Linux. The fastest switching between Windows and Linux through Alt+Tab (no restarting or rebooting needed):
Install CoLinux
Use CoLinux root file system image: Ubuntu-9.04-1gb.7z
Start CoLinux
Change string archive.ubuntu.com to old-releases.ubuntu.com with:
$ sudo vi /etc/apt/sources.list
Update your configuration:
$ sudo apt-get update
Install two software packages to be able to compile your programs (c/c++, gcc compilers, mysql dev 5.1):
$ sudo apt-get install build-essential
$ sudo apt-get install libmysqlclient15-dev
Accessing Windows directories from CoLinux:
$ mount cofs0 /mnt/ -t cofs
$ cd /mnt
Compile
$ c++ your.source.cc -o executable.name
Are you asking for something that can take code written to run on Windows and make it run on linux? There's not really a compiler that does that - but maybe you're looking for Wine ( http://www.winehq.org/ ) which lets you run Windows apps on linux (if they use APIs Wine has thunked out).
Edit: I'm assuming your code is using Windows APIs (Win32, etc.) in this answer. If you're only using Standard C++ and libraries available cross-platform, then there's lots of other answers.
I don't believe there are any compilers that allow you to compile on Windows and then take the resulting binary and run it on a Linux machine. Your best bet is to set up two development environments, one on Windows and one on Linux. Do most of your development and debugging in the Windows environment if that's what suits you, then frequently compile and test under Linux to be sure your code is truly cross-platform. You'll also want to use a cross-platform build system and testing framework. I recommend using cmake and Google Test, respectively.