0

Im trying to build a PortMidi example in Mingw but it depends on two libraries portmidi and winmm, I recompiled portmidi to get a portimidi.a but Im getting errors of missing code.

Is posible to link winmm to mingw, and I have to use ".a" or ".lib" libraries?

Im using this command to compile the source:

g++ -o prg latency.c -IHeaders -LLib -lportmidi -lwinmm 

Thanks for your help.

moskito-x
  • 11,832
  • 5
  • 47
  • 60
Alex Ar
  • 37
  • 1
  • 7
  • I used this command to compile the example "gcc -o prg latency.c -IHeaders -lportmidi -lwinmm" and copy portmidi to lib folder in mingw – Alex Ar Aug 16 '13 at 19:49

1 Answers1

1

You don't need winmm.a to build latency.c

you need
libpmjni.dll.a , libportmidi.dll.a or
libportmidi_s.a

To build portmidi wit CMake takes 5 minutes.

  • portmidi source : c:/src/portmidi217/
  • portmidi build : c:/minGW/portmidi

Then you can compile it with the following command.

gcc.exe  -c -g -I/c/src/portmidi217/pm_common -I/c/src/portmidi217/porttime -MMD -MP -MF build/Debug/latency.o.d -o build/Debug/latency.o latency.c
mkdir -p dist/Debug
gcc.exe  -o dist/Debug/latency build/Debug/latency.o -L/c/minGW/portmidi -lpmjni.dll -lportmidi.dll 


Building portmidi with CMake

  • Download or use Cmake
  • in c:\cmake\bin folder double click cmake-gui.exe

unzip portmidi to the folder c:\minGW\src\portmidi217 you can see in the next image
(replace all T:\ with C:\ of course)

enter image description here

press configure

enter image description here

settings as described --> click next

enter image description here

settings as described --> click ok

enter image description here

there a errors so click configure again

enter image description here

next looks better click configure again

enter image description here

settings as described Release or Debug
maybe it worked without c:\msys\1.0\bin\sh.exe
click configure again

enter image description here

looks good --> click Generate

enter image description here

cd to your just builded c:\minGW\portmidi

enter image description here

open windows command type make

enter image description here

it takes a short time to build

enter image description here

there they are : .a and .dll

enter image description here

  • copy all .a to c:\minGW\lib
  • copy all .dll to c:\minGW\bin
  • copy from C:\minGW\src\portmidi217\pm_common and C:\minGW\src\portmidi217\porttime
    all .h to the folder where your latency.c is.

Then you can latency.c compile as described above, you just need to adjust the paths.

moskito-x
  • 11,832
  • 5
  • 47
  • 60
  • Thanks but libpmjni.dll.a uses java and I'm Trying to build it completely in c++ that's why I need to link winmm. I found that winmm exists as libwinmm.a in mingw's lib files but I tried to link it with -llibwinmm command with no success. Please help me. – Alex Ar Aug 11 '13 at 21:11
  • I build it completely in C++ winmm is automatic linked to `C:\WINDOWS\system32\winmm.dll` it's a dll by system ! have you build portmidi with cmake to create the makefiles done in 5 minutes and compile with gcc `latency.c` in 1 minute it's very easy. – moskito-x Aug 11 '13 at 21:19
  • Can you help me with the command or cmake file please, Im having problems with cmake – Alex Ar Aug 11 '13 at 23:03
  • Wow!! really thanks for your effort aswering my question, I wish some day I could help you..... Really thanks let me know if you need something – Alex Ar Aug 12 '13 at 20:51
  • No now Im getting this "Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)" I already installed the jdk why is this? – Alex Ar Aug 16 '13 at 16:39