質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top