PURE DATA forum~

...that deal with pure data

You are not logged in.

  • Index
  • » extra~
  • » problem compiling external on Windows

#1 2007-06-24 23:37:13

middlepedal
Member

problem compiling external on Windows

I'm having trouble getting the helloworld external to compile properly on Windows.

The main resource is apparently this: HOWTO write an External for puredata, and some previous posts on this topic are here: Compiling new external, Max/MSP microtuning externals to convert to pd

Bear with me, because working with the C compiler is still rather mysterious to me, so I may be making some obvious mistakes. I've installed the djgpp compiler, and followed all the instructions as best as I could. I'm working on XP. I put "m_pd.h" (from the pd/src/ folder) and "helloworld.c" in the same folder and from that directory on the command line (in a DOS "Command Prompt" window) typed:

gcc -c helloworld.c -o helloworld.o

As far as I can tell, this successfully produced the "helloworld.o" object file in the same directory as the "helloworld.c" file. Then I typed:

ld -export_dynamic -shared -o helloworld.dll helloworld.o -lc -lm

Which, as I understand, is the "linking" step, and the only difference between this command and the command for linux is that ".pd_linux" is replaced with ".dll". Anyway, the compiler responded with:

c:/progra~1/djgpp/bin/ld.exe: -shared not supported

So, not having any other ideas, I tried omitting the -shared flag:

ld -export_dynamic -o helloworld.dll helloworld.o -lc -lm

That produced this response:

c:/progra~1/djgpp/bin/ld.exe: warning: cannot find entry symbol xport_dynamic; defaulting to 000018d0
helloworld.o:helloworld.c:(.text+0x1e): undefined reference to `post'
helloworld.o:helloworld.c:(.text+0x37): undefined reference to `pd_new'
helloworld.o:helloworld.c:(.text+0x60): undefined reference to `gensym'
helloworld.o:helloworld.c:(.text+0x79): undefined reference to `class_new'
helloworld.o:helloworld.c:(.text+0x96): undefined reference to `class_addbang'


Why is -shared not supported and what can I do to fix that? I tried Microsoft Visual C++ Express Edition, but found the interface bewildering. I don't think I could even find the words "compile" and "link" in any menu...

Then I looked in the "0.README" file located in the pd/doc/6.externs/ directory, and found this line (in reference to the 3 example enternals in that folder):

To compile, type "make pd_linux", "nmake pd_nt", "make pd_irix5" or "make pd_irix6".

If I wanted to compile these, where would I even type this? Is "nmake" an actual command?

Then I tried poking around the GNU info files, and saw some vague information about "binutils" and "dlltool" but it is so beyond me right now that I'm turning here. Could someone please enumerate the steps required to take the C source file "helloworld.c" and make it into a usable object in pd without skipping any steps? I (and I'm sure many others) would greatly appreciate that.

Thanks in advance!

Offline

 

#2 2007-06-27 22:17:20

pycos
Member

Re: problem compiling external on Windows

Hi ! That was just to say that I'd really appreciate an answer to this question to. I tried exactly the same things than middlepedal, and then I had no more ideas...
Please help !!!

Offline

 

#3 2007-06-27 22:59:43

obiwannabe
Administrator

Re: problem compiling external on Windows

This has been answered on pd-list today
Hopefully this is helpful to others. I never go near Windows myself,
but anyway, post copied verbatim for the benefit of all...


> Iohannes Zmoelnig wrote:

> have you tried any online resources: e.g.
> http://puredata.info/docs/developer lists at least 2 pages that only
> deal with compiling on windows
> (http://puredata.info/docs/developer/mingw which basically deals with
> compiling pd itself on windows; but once you are there, it is simple;
> http://nul.jp/2002/pd_bc deals with compiling externals with the
> borland-compiler).

> i can give you a step-by-step guide for compiling zexy though (but mind
> that this is how i _remember_ it; i will not go and search for a windows
> machine with VC installed just to verify each step).

> - purchase M$ VC6 (elitarism on my side...:-)) and install it
> - get pd
> - download zexy (sources!) for free (e.g.
> ftp://ftp.iem.at/pub/pd/Externals/ZEXY/)
> - extract zexy to you favourite folder
> - double-click on the zexy.dsp (or was it zexy.dsw??) in the zexy/src/
> folder; this should open VC
> - to to the Project->Properties (or however this is called in your
> locale) and change the settings to match your setup (mainly these are
> the paths to find pd's headers and libraries; you should basically go
> through every item in the settings for the "release" and/or "debug"
> builds; the most important stuff is in "compiler->preprocessor",
> "compiler->path" and "linker->path"
> - when you are finished, return to the main project window
> - hit "F7" to start the build.
> - if you encounter any errors, either the settings are not yet correct
> (return to item-6) or the project is a bit out-of-date; the latter
> basically means, that the c-files to be included have not been updated;
> to fix this, just delete all the c-files from the project file browser
> (here this used to be un the left-side of the project-window), then
> right click on the folder in the project file browser that used to
> contain these files and select "add"; in the openpanel choose all
> c-files in zexy/src and hit "OK"
> - return to item-8 until you stop getting errors

> mind, that you must not use the dll while it is created (best close pd)

> if you want step-by-step instructions for vc7, vc2000, vc2006 and
> vc3000, please send them to me and i'll give it a go :-) (dev-elitarism
> again)


> pd comes with some externals (e.g. the foo-stuff, or [fiddle~]) and uses
> makefiles to build these.
> for this to work, you have to setup your environment correctly:
->  first open the makefile (e.g. pd/doc/6.externs/makefile) with your
> favourite text-editor and correct all the paths that are wrong
> - VC6 came with a vc6vars.bat (ok the name is wrong but something along
> these lines; it was a .bat-file which would set your envirnment
> variables when run; more modern incarnations might do without the .bat
> - open the dosbox (the rest will happen within the dosbox)
> - run the vc6vars.bat (or however it is called) if this is needed for
> your compiler-incarnation
> - cd to your path (e.g. pd/doc/6.externs/)
> - run "nmake pd_nt"

> if nmake, cl, link cannot be found, you might want to add the paths to
> them to your PATH variable.


Martin Peach wrote:

> If you're on some kind of MSVC, you set up a project to build a dll, in
> "preprocessor defines" define MSW, in "additional include paths" include
> the path to pd/src/m_pd.h, link with pd.lib from pd/bin, and in the
> linker command line add "/export:yourexternal_setup" to export the setup
> function. All the other functions in your code can be static and don't
> need to be exported. After it builds you take the dll from the release
> folder and put it in your pd/extra folder.
> That should be everything you need, but if it's too cryptic I can go
> into more detail...

> Martin


Use the Source.

Offline

 

#4 2007-06-27 23:47:15

pycos
Member

Re: problem compiling external on Windows

Ok thanks for your help. I'll try it tomorrow
bye

Offline

 

#5 2007-06-29 08:33:21

middlepedal
Member

Re: problem compiling external on Windows

Hey,

thanks to everyone who responded to my posts both here and in the mailing list. Since then, I've figured out how to compile externals written in C using Microsoft Visual C++ 2005. There's more to document, however, such as how to compile externals using some of the other Windows compilers (Borland, djgpp, etc.), and also how to compile externals written in C++ in Windows. But one thing at a time.

one little thing to note... steps 4 and 7 may seem a little roundabout, but they account for the fact that MSVC sometimes has trouble with spaces in directory names (eg. C://Program Files/). If anyone knows how to override this behavior, post a reply, and I'll try to simplify the steps accordingly.

Updated June 29, 2007:
     use C://Progra~1/ instead of C://Program Files/,
     use C://Docume~1/ instead of C://Documents and Settings/, etc.


So, without further ado...

How to compile a pd external written in C using Microsoft Visual C++ 2005:

Compared to Windows, linux offers a much more user-friendly environment for compiling pd externals. However, with a little patience, a usable environment can be set up in Windows, and the good news is that everything you need is available for free. There are several reputable Windows-compatible C/C++ compilers out there, but here I'll discuss compiling externals with Microsoft Visual C++ 2005 (MSVC for short).

1. Download and Install Microsoft Visual C++ 2005 Express Edition.
    a. Click the link above, then click Go! in the Visual C++ box.
    b. Run vcsetup.exe to install the program
        (the setup wizard should guide you through the process).

2. Download Visual C++ 2005 Express Service Pack 1.
    a. Click the link above to download the Service Pack.
    b. Run VS80sp1-KB926748-X86-INTL.exe to install the program.

3. Create a new project:
    a. Open Visual C++.
    b. Open the New Project window (Ctrl+Shift+N).
    c. In the Project Types pane, select Visual C++.
    d. In the Templates pane, select emptyproj.
    e. Enter object name (helloworld).
    f. Leave Create directory for solution unchecked, and click OK.

4. Import the pd header file:
    a. Get m_pd.h here, or, using pd-vanilla (not pd-extended):
           1. Open Windows Explorer or My Computer.
           2. Navigate to the pd/src/ directory on your system.
           3. Open m_pd.h in a text editor (file type is: C/C++ header).
    b. Select all (Ctrl+A).
    c. Copy selection to the clipboard (Ctrl+C).
    d. Back in Visual C++, open the New File window (Ctrl+N).
    e. In the Categories pane, select General.
    f. In the Templates pane, select Text File, and click Open.
    g. Copy the contents of m_pd.h into the editor window (Ctrl+V).
    h. Open the Save File As Window (Ctrl+S).
    i. Save as m_pd.h.
    j. From the File Menu, select Move m_pd.h into; select helloworld.

5. Write the source code for the external in C.
    a. Open the New File window (Ctrl+N).
    b. In the Categories pane, select General.
    c. In the Templates pane, select Text File, and click Open.
    d. Write your source code in the editor window.

The following example is taken from the tutorial by Johannes M. Zmoelnig.

Code:

#include "m_pd.h"

static t_class *helloworld_class;

typedef struct _helloworld {
  t_object  x_obj;
} t_helloworld;

void helloworld_bang(t_helloworld *x)
{
  post("Hello world !!");
}

void *helloworld_new(void)
{
  t_helloworld *x = (t_helloworld *)pd_new(helloworld_class);

  return (void *)x;
}

void helloworld_setup(void) {
  helloworld_class = class_new(gensym("helloworld"),
        (t_newmethod)helloworld_new,
        0, sizeof(t_helloworld),
        CLASS_DEFAULT, 0);
  class_addbang(helloworld_class, helloworld_bang);
}

6. Save and import the source code into the project:
    a. Open the Save File As Window (Ctrl+S).
    b. Save as helloworld.c.
    c. From the File Menu, select Move helloworld.c into; select helloworld.

7. Access the pd library file:
    a. Open Windows Explorer or My Computer.
    b. Navigate to the pd/bin/ directory on your system.
    c. Right-click on pd.lib (file type is: Object File Library) and select Copy.
    d. Navigate to the C://TEMP/ directory on your system.
    e. Paste the copy of pd.lib in the C://TEMP/ directory (right-click or Ctrl-V).

8. Set configuration properties:
    a. Set configuration type to .dll:
        1. Back in Visual C++, open the helloworld Property Pages window (Alt+F7).
        2. In the left pane, select Configuration Properties >> General.
        3. In the right pane, under Project Defaults, click on
            Configuration Type, and select Dynamic Library (.dll)
            (using the arrow on the right).

    b. Add MSW to preprocessor definitions:
        1. In the left pane, select
            Configuration Properties >> C/C++ >> Preprocessor.
        2. In the right pane, type MSW in the Preprocessor Definitions field.

    c. Tell compiler which language to use:
        1. In the left pane, select
            Configuration Properties >> C/C++ >> Advanced.
        2. In the right pane, select Compile As.
        3. Select Compile as C Code (/TC) by clicking the arrow on the right.

    d. Tell linker where to find pd.lib:
        1. In the left pane, select Configuration Properties >> Linker >> Input.
        2. In the right pane, select Additional Dependencies and enter
            C://TEMP/pd.lib.

    e. Tell linker to export the setup function:
        1. In the left pane, select
            Configuration Properties >> Linker >> Command Line.
        2. In the right pane, type
            /export:helloworld_setup in the Additional options field.
        3. Click OK.

9. Compile and link:
    a. Use the Build Solution command (F7).

10. Copy the new helloworld.dll file into pd.
      a. Open Windows Explorer or My Computer.
      b. Navigate to the
          My Documents/Visual Studio 2005/Projects/helloworld/Debug/
          directory on your system.
      c. Right-click on helloworld.dll (file type is: Application Extension)
          and select Copy.
      d. Navigate to the pd/extra directory on your system.
      e. Paste the copy of helloworld.dll in the pd/extra directory
          (right-click or Ctrl-V).

11. Test the external in pd.
      a. the external should now be a useable object in pd.
      b. open a new pd patch and try to create a helloworld object.
      c. add a bang to the left inlet and test it out.
      d. if the main pd console window displays "Hello world !!",
          the external has succeeded.

Hope this helps!
-- middlepedal

Last edited by middlepedal (2007-06-30 04:01:38)

Offline

 

#6 2007-06-29 11:33:51

AlbertoZ
Member

Re: problem compiling external on Windows

Great tutorial, very detailed!
Thanks for this addition..

Sorry for coming later on this subject but I'll try to add few lines about
compiling externals in Win without going through MSVC Express
edition (by the way: what are the limitations of the express edition
w.r.t. the full package?).
Even if MSVC offers an integrated environment for developing there
can be some good reasons for giving a try to the old-man "unix" way of
compiling, which in windows is best represented by MINGW32 and
cygwin. Both offers linux-like environments (i.e. command line tools)
for compiling and other shell tasks which, sometimes, in windows are
a pain in the ass.
There are at least three good reasons for giving a look at mingw:

1) gives strong linux compatibility on external compilation
    (almost same command lines arguments etc.)
2) there is the possibility to use makefiles in an almost straightforward way
    (with minor modifications to linux makefiles).
3) no dependency on expensive MS programs (except for the
    small, bug-free Operating System ;-)

I did this exercise by porting the E. Lyon "LyonPoutpourry" externals for win
(http://www.sarc.qub.ac.uk/~elyon/LyonSoftware/Pd/). Give a look at
the win source package: inside there is a makefile for darwin (MAC)
linux and win. I added the latter, and as you can see the modifications
are minor.   

----------- 1. Prelude: compilation environment ------------------

First of all we have to set once for all the compilation environment.
Let's forget for the moment cygwin and concentrate on mingw32 (http://www.mingw.org/). The following is taken from (H.C. Steiner's wiki http://www.puredata.org/docs/developer/mingw)

Download the MinGW package installer and run it:
(http://prdownloads.sourceforge.net/ming … -5.1.1.exe)     
Choose the Candidate distribution. Install the defaults and add the g++ compiler, g77 compiler, and MinGW make or you can just download my MinGW install, MinGW-Pd.tar.bz2, and uncompress it so that its installed into C:\MinGW.

Then we need MSYS which is a shell (an interpreter of the commands, like a
colorful dos prompt ;-)
http://prdownloads.sourceforge.net/ming … 1.0.10.exe

Now you will be using the MSYS shell that was installed from the MSYS installer. You can launch it from the Desktop shortcut or Start -> Programs -> MinGW -> MSYS -> msys

----------- 2. Allegro: compilation trial ------------------

a. open MSYS

b. at the prompt type:
cd c:
(or the drive you whish to go for the pd external compilation)

c. go to the external directory (note the backslashes instead of slashes !),
mine is external-compiling. Inside I have helloworld.c
cd alberto/backup/PureData_Archive/patches/AlbertoZ/external-compiling/

d. copy m_pd.h (from the PD distribution directory) into external-compiling
(or whatever is its name)

e. type:
gcc -c helloworld.c -o helloworld.o

f. type:
ld -export_dynamic -shared -o helloworld.dll helloworld.o c:/Programmi/pd039e
xt4/bin/pd.dll

(this is the linker step. note that I linked to a particular version of pd.dll - 0.39 extended test 4, so probably (I'm not sure about this) the external will
run on 0.39 only. Can someone confrm this?)

g. If everything was ok then you should have a helloworld.dll in your
directory. Move it on the extra folder of your pd distribution
(I assume that extra folder is in the pd predefined path) and make a
new patch with the helloworld object.  Again, if everything is correct,
you should have a "Hello world!!" printed on the console.

----------- 3. Adagio: makefile ------------------

A makefile can be used for compilation. Even if a simple helloworld
application does not need it, complex programs may do.

The makefile.win is attached with this post. Modify it according to your
path in 
Make sure you have

helloworld.c
m_pd.h
makefile.win

in your directory. Now type at MSYS prompt:

make -f makefile.win

This will automatically produce:
the object, the linker step (the dll) and will copy the helloworld.dll
in the extra folder of you pd distribution (overwriting the existing one ;-).

----------- 4. Allegro con brio: conclusions ------------------

Why not give a try to the old-man compilation on Win?
:-)

----------- 5. Minuetto: greetings ------------------

I apologize if I said some crap somewhere, just let me know if it
doesn't work. Have fun!
 
Best regards,

Alberto

Offline

 

#7 2007-06-29 11:35:09

AlbertoZ
Member

Re: problem compiling external on Windows

Whoops!

Attached here the makefile.

Alberto


Attachments:
Attachment Icon Makefile.win, Size: 894 bytes, Downloads: 111

Offline

 

#8 2007-06-30 06:17:37

middlepedal
Member

Re: problem compiling external on Windows

Alberto,

Awesome contribution to the forum! Thanks to your post, I've gotten things to work with MinGW. In fact, the helloworld.dll file produced with the MinGW method was only 6.19 KB, tiny compared to MSVC's 52 Kb file. Not exactly sure why this is, perhaps MSVC uses a bunch of unnecessary default settings that eat up space?

Anyway, I'd like to add a note of caution to readers about to download and install MinGW and MSYS: read this. Main points:

     1. install MinGW first, then MSYS.
     2. before installing MSYS, make sure you know where MinGW is (eg.
         C://Program Files/MinGW).
     3. when MSYS asks you where MinGW is, use only lowercase letters,
         and convert directory-names with spaces to shorter forms (eg. type
         c:/progra~1/mingw instead of C://Program Files/MinGW).
     4. if the "normalizing" step fails for any reason, uninstall MSYS, and
         reinstall it "with greater care"...

Also, I tried using your makefile as you said, but got the response:

     make: Nothing to be done for `current'.

I'm not so smart about makefiles (yet), and I'm confused by your suggestion to "Modify it according to your path in". I changed 2 lines:

     DEST = "c:/Progra~1/pd/extra"
     PDPATH = "c:/Progra~1/pd"


and the got the response above.

Two more things: about the difference between MSVC and MSVC Express, I have no idea. And finally, where is MSYS-1.0.11.exe, mentioned here?

Thanks again,
Middlepedal

Last edited by middlepedal (2007-06-30 06:18:09)

Offline

 

#9 2007-06-30 23:46:10

middlepedal
Member

Re: problem compiling external on Windows

Alberto,

I figured it out. I made a few changes to your makefile, though:
     1. added a path to m_pd.h
     2. changed "rm -f $*.o ../$*.dll" to "rm -f $*.o $*.dll"
         (the .dll file wasn't being removed from the working directory)
     3. forced DEST to the pd/extra directory
     4. removed CSYM since it's not being used
     5. removed "current: pd_win"; changed "pd_win: $(NAME).dll" to "all: $(NAME).dll"
     6. removed non-win stuff
     7. removed the clean and install targets for right now
Hopefully these changes make it easier for the complete newbie. Anyway, with enormous thanks to AlbertoZ, here's a mini-tutorial for using my makefile.

1. if you're using pd-extended, save this as "m_pd.h" (into the same directory with
    helloworld.c). If you're using pd-vanilla, you can skip this step.
2. save this code as "mk.mk" (into the same directory with helloworld.c):

Code:

# mk.mk -- invoke with "make -f mk.mk"

      NAME = helloworld
    PDPATH = "c:/Progra~1/pd"
   LDFLAGS = --export-dynamic -shared
WININCLUDE = -I $(PDPATH)/src
 WINCFLAGS = -DPD -DNT -W3 -WX -Werror -Wno-unused          \
             -mms-bitfields -Wno-parentheses -Wno-switch    \
             -O6 -funroll-loops -fomit-frame-pointer

all: $(NAME).dll
.SUFFIXES: .dll
.c.dll:
    gcc $(WINCFLAGS) $(WININCLUDE) -c -o $*.o $*.c
    gcc $(LDFLAGS) -o $*.dll $*.o $(PDPATH)/bin/pd.dll     
    strip --strip-unneeded $*.dll
    cp $*.dll $(PDPATH)/extra
    rm -f $*.o $*.dll

2. modify the PDPATH variable if needed to reflect the actual location of pd on your
    system (MSYS will interpret c:/Program Files/pd as C:/Program, so use
    c:/Progra~1/pd instead)
3. if you're using pd-extended, remove line 6 (WININCLUDE = -I $(PDPATH)/src) and
    remove $(WININCLUDE) from line 14.
4. close all pd windows if any are open
5. in MSYS, navigate to the directory with helloworld.c and type: make -f mk.mk
    (type make -s -f mk.mk if you want to hide the lengthy shell response)
6. the shell should respond with something like:
     gcc -DPD -DNT -W3 -WX -Werror -Wno-unused -mms-bitfields -Wno-parentheses
     -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -I "c:/Progra~1/pd"/src -c -o
     helloworld.o helloworld.c
     gcc --export-dynamic -shared -o helloworld.dll helloworld.o
     "c:/Progra~1/pd"/bin/pd.dll
     strip --strip-unneeded helloworld.dll
     cp helloworld.dll "c:/Progra~1/pd"/extra
     rm -f helloworld.o helloworld.dll

7. a new helloworld.dll file should be saved into the pd/extra folder, and you should be
    able to create the "helloworld" object in a new pd window.

Good luck!
middlepedal

Last edited by middlepedal (2007-07-01 20:12:35)

Offline

 

#10 2007-07-01 10:12:16

AlbertoZ
Member

Re: problem compiling external on Windows

Hi Middlepetal,

I also noticed that Mingw externals are "thin" instead of
the fat MSVC. Dunno why exactly. For sure the

strip --strip-unneeded $*.dll

strips everything unnecessary out from the .dll

Yes, you tailored the makefile perfectly for the
helloworld project. When you start mastering makefiles there is no
way back ;-).

Regarding

>Also, I tried using your makefile as you said, but got the response:
>
>     make: Nothing to be done for `current'.

be sure to first remove the .o and .dll from the current directory
that you probably had produced by compiling manually from
command line.

PS: how do you make colored, bold text in the forum?
I didn't realize it was possible :-0

cheers,

Alberto

Offline

 

#11 2007-07-01 19:48:18

middlepedal
Member

Re: problem compiling external on Windows

AlbertoZ,

here's the info on formatting your forum posts:
http://puredata.hurleur.com/help.php.

Have fun!
middlepedal

Offline

 

#12 2007-07-03 10:07:09

jogistar
Member

Re: problem compiling external on Windows

Thanks for the detailed tutorial

>7. Access the pd library file:
>    a. Open Windows Explorer or My Computer.
>    b. Navigate to the pd/bin/ directory on your system.
>    c. Right-click on pd.lib (file type is: Object File Library) and select Copy.
>    d. Navigate to the C://TEMP/ directory on your system.
>    e. Paste the copy of pd.lib in the C://TEMP/ directory (right-click or Ctrl-V).

Where can I find the pd.lib file? I'm using pd-extended, and there is not a single .lib file in my pd/bin directory.

-JoGi

Offline

 

#13 2007-07-03 17:00:49

AlbertoZ
Member

Re: problem compiling external on Windows

jogistar wrote:

Where can I find the pd.lib file? I'm using pd-extended, and there is not a single .lib file in my pd/bin directory.

Mmmh, I was not able to find it too in my pletora of win PD distributions. 
I suspect pd.lib is:

a) pd.dll, which is a "dynamically linked library" in windows (and by chance
it is referred as pd.lib), which is located in pd/bin
b) pd.dll as seen by MSVC integrated environment (???).

Boh... let us know... otherwise try the dark side of the force (MinGW way) :-)

All the best,

Alberto

Offline

 

#14 2007-07-04 05:16:26

middlepedal
Member

Re: problem compiling external on Windows

AlbertoZ wrote:

jogistar wrote:

Where can I find the pd.lib file? I'm using pd-extended, and there is not a single .lib file in my pd/bin directory.

Mmmh, I was not able to find it too in my pletora of win PD distributions.
I suspect pd.lib is:

a) pd.dll, which is a "dynamically linked library" in windows (and by chance
it is referred as pd.lib), which is located in pd/bin
b) pd.dll as seen by MSVC integrated environment (???).

Hi all,

I don't think pd.lib is the same as pd.dll. pd.lib, as appears in pd-vanilla, also does not appear to be in the CVS repository. I've included pd.lib as an attachment with this post, but you must be a member to download the attachment (membership is free).

Hope it helps,
middlepedal


Attachments:
Attachment Icon pd.lib, Size: 87,630 bytes, Downloads: 98

Offline

 

#15 2007-07-04 09:01:19

jogistar
Member

Re: problem compiling external on Windows

Thanks AlbertoZ!

It took me some courage to try the old-man unix style compilation, but it did work and I got my "Hello World!" printed out. All in all it took me maybe in 15 minutes.

You really should make a wiki-page out of this to puredata.org!


It's just a fact that people are scared of unknown... if one is not used to use Unix, then the cryptic lines like the following are very scary:

>f. type:
>ld -export_dynamic -shared -o helloworld.dll helloworld.o c:/Programmi/pd039e
>xt4/bin/pd.dll


It would make it easier if you could even very shortly explain what's going to happen in each step. For example this was useful small note:
"Then we need MSYS which is a shell (an interpreter of the commands, like a colorful dos prompt ;-)"

In the original wiki (http://puredata.org/docs/developer/mingw) it was only:
"Install this with all of the defaults: MSYS-1.0.10.exe"

For a scary windows-person like me it's nice to know why I should install that.

In your wiki page you could link also the followink make-file tutorial:
http://www.eng.hawaii.edu/Tutor/Make/index.html


Thanks a lot,

-JoGi

Offline

 

#16 2007-07-05 15:08:49

jogistar
Member

Re: problem compiling external on Windows

I found also a nice tutorial on how to compile the "Hello world" example with DevC++ free integrated development environment.

http://www.youngmusic.org/wiki/index.ph … g-tutorial

Offline

 

#17 2008-06-13 00:06:36

gyokimae
Member

Re: problem compiling external on Windows

Hi, sorry to pull up this old topic.

This somewhat overlaps with my recent post to [pd-dev] list.
After the posting, I had made some progress and came up with a new question while discovering this thread which seemed very relevant.


Struggling to get my externs built on Windows, I've been working both in VC++ Express 2008 and MSYS.


Under both environments, the "hello world" code on the "EXTERNALS HOWTO" page build fine. Well, with minimal knowledge of C and zero experience in mangling with existing OSS, I did spend a good amount of time with VC++ before reaching configurations identical to ones mentioned earlier in this thread.

However, with the next "counter" example, I would face problems related to the fact that "s_float" cannot resolved.


Under VC++, the link would simply fail due to the unresolved _s_float symbol... until this morning.. I've tried linking to the pd.lib file contained in a version of Pd later than I tried earlier in order to gather error messages for this post. For some reason it seems to work now.

The situation remains the same with MSYS.
I get the following message during linking. Although the .dll file is created, Pd does not load the external properly.

$ ld -E -shared -o gcounter.dll gcounter.o pd.dll
Info: resolving _s_float by linking to __imp__s_float (auto-import)

(gcounter is just a name a gave to the simple counter example to avoid conflict with existing objects in pd-extended)


After working on this for a few nights, I've finally got files built in VC++ working so I am somewhat relaxed now.
I would, however, appreciate advise on what may be going on with the MSYS builds. Again, "helloworld" builds and runs great. Only after s_float symbols are introduced do I see behaviors I cannot understand.


Thanks.

--
David Shimamoto

Offline

 

#18 2008-07-18 12:39:59

joelakes
Member

Re: problem compiling external on Windows

Hi David,

Did you resolve the problems with the $s_float in the counter example? I am getting the same problem using Dev-C++.

Thanks,
Joe

Offline

 

#19 2009-02-04 13:57:28

teaiki
Member

Re: problem compiling external on Windows

Hello everybody,

I'm working with files that was written several years ago on other Windows versions. I have to compile an external in order to start my real work, but I'm not an expert in C programming.

I've tried to compile the DLL with both Visual C++ 2008 and MinGW. I'm not Trying to compile helloworld.c but another file (M2M~.c) that I have to work with. I have many header files (.h) associated with M2M~.c.

With Visual C++ 2008, I have done exactly the same thing than middlepedal but I cannot compile, I have an error message such as (this is in french) :

Édition des liens en cours...
LINK : error LNK2001: symbole externe non résolu M2M~_setup
C:\Users\Teaiki\Documents\Visual Studio 2008\Projects\M2M~\Debug\M2M~.lib : fatal error LNK1120: 1 externes non résolus

Is there a great différence between Visual C++ 2008 and Visual C++ 2005?

With MinGW, I have done exactly the same thing than AlbertoZ, and I have a lot of error message such as : "undefined reference to ..."

What should I do?

Can someone help me please?

Thank you in advance

Teaiki

Offline

 

#20 2011-06-17 22:44:53

twelti
Member

Re: problem compiling external on Windows

Dunno if this thread is completely dead, but:

I followed instructions int his thread and got the helloworld to build in VS2005.  I compiled in debug mode.  The helloworld.dll loads and works in PD.  BUT, if I switch to relese mode, pd crashes every time.  I have been fiddling aournd with some of the settings and it seems that the "Generate Debug info" is the culprit.

Any help appreciated, I'm going nuts here.

Offline

 

#21 2011-09-19 18:09:17

twelti
Member

Re: problem compiling external on Windows

I also ended up compiling in MinGW, with eventual success and not too much trouble.  I had to figure out how to do a build file (most of my limited experience is in VS), but not too hard.

Offline

 

#22 2011-10-18 18:43:37

twelti
Member

Re: problem compiling external on Windows

You mean like this one?
Yes, I have been all over the internet.  Like I said, I eventually solved my problem using MinGW.  I don't know why it worked and VS had a problem.  Probably my own lack of experience had something to do with it.

Offline

 

#23 2011-11-13 18:19:39

Psyko Logical
Member

Re: problem compiling external on Windows

joelakes wrote:

Hi David,

Did you resolve the problems with the $s_float in the counter example? I am getting the same problem using Dev-C++.

Thanks,
Joe

I was having the same problem. Also in the [pan~] signal class example with &s_signal.

But I finally solved it, or at least found a way around it that seems to work.
In How to Write PD Externals there's a line explaining that s_signal refers to the
string "signal" in a lookup table somewhere, so I tried to just replace &s_signal with "signal" each place it was used. Of course, this didn't work.

Later I noticed that anywhere else a string appeared, it was added with gensym("string"). So this time I replaced &s_signal with gensym("signal") and it actually worked.

My ideas on what's going on are either:
  A. The external is compiled before "signal" is added to the table.
  B. "signal" is never added to the table, unless you do it
  C. The external can't see the table, for what ever reason.

These are just guesses. I'm learning as I go, and not very familiar with C yet.

I would like to know however if this is a good practice or a hack.
Also, should I use gensym() every time s_signal appears, or does it just need to be called once? ie Will it cause any problems to call gensym() multiple times with the same argument?

Hopefully this will help someone else out there having the same problem.

Offline

 
  • Index
  •  » extra~
  •  » problem compiling external on Windows

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson


pd.webring info