diff --git a/configure.ac b/configure.ac
index a8926e66f8..3ba77eeb93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1415,9 +1415,25 @@ PKG_CHECK_MODULES([G7221], [g722_1 >= 0.2.0],[
AM_CONDITIONAL([HAVE_G7221],[true])],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_G7221],[false])])
-PKG_CHECK_MODULES([CODEC2], [codec2 >= 0.2],[
- AM_CONDITIONAL([HAVE_CODEC2],[true])],[
- AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_CODEC2],[false])])
+codec2="true"
+PKG_CHECK_MODULES([CODEC2], [codec2 >= 0.5],[],[
+ AC_CHECK_LIB([codec2], [codec2_create],[
+ AC_CHECK_HEADERS([codec2/codec2.h],[
+ CODEC2_LIBS="-lcodec2"
+ CODEC2_CFLAGS=""
+ ], [
+ codec2="false"
+ if module_enabled mod_codec2; then
+ AC_MSG_ERROR([You must install libcodec2-dev to build mod_codec2])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ ])
+ ])
+])
+
+AM_CONDITIONAL([HAVE_CODEC2],[$codec2])
+
PKG_CHECK_MODULES([OPUS], [opus >= 1.1],[
AM_CONDITIONAL([HAVE_OPUS],[true])],[
diff --git a/libs/win32/libcodec2/generate.bat b/libs/win32/libcodec2/generate.bat
index 4503b2667c..59a6bcfeb1 100644
--- a/libs/win32/libcodec2/generate.bat
+++ b/libs/win32/libcodec2/generate.bat
@@ -3,7 +3,7 @@ REM In order to regenerate headers
REM execute this generate.bat from the "VS2015 x86 Native Tools Command Prompt"
REM
-cd ../../libcodec2-2.59/src
+cd ../../libcodec2-2.59/codec2
cl /EHsc generate_codebook.c
generate_codebook.exe lsp_cb codebook/lsp1.txt codebook/lsp2.txt codebook/lsp3.txt codebook/lsp4.txt codebook/lsp5.txt codebook/lsp6.txt codebook/lsp7.txt codebook/lsp8.txt codebook/lsp9.txt codebook/lsp10.txt > codebook.c
generate_codebook.exe lsp_cbd codebook/dlsp1.txt codebook/dlsp2.txt codebook/dlsp3.txt codebook/dlsp4.txt codebook/dlsp5.txt codebook/dlsp6.txt codebook/dlsp7.txt codebook/dlsp8.txt codebook/dlsp9.txt codebook/dlsp10.txt > codebookd.c
diff --git a/libs/win32/libcodec2/libcodec2.2017.vcxproj b/libs/win32/libcodec2/libcodec2.2017.vcxproj
index f43955c944..adc1f8a356 100644
--- a/libs/win32/libcodec2/libcodec2.2017.vcxproj
+++ b/libs/win32/libcodec2/libcodec2.2017.vcxproj
@@ -119,57 +119,57 @@
-xcopy "$(ProjectDir)generated\*" "$(libcodec2LibDir)\src\" /C /D /Y
+xcopy "$(ProjectDir)generated\*" "$(libcodec2LibDir)\codec2\" /C /D /Y
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mod/codecs/mod_codec2/mod_codec2.c b/src/mod/codecs/mod_codec2/mod_codec2.c
index 9edd464197..cdbdfbdf72 100644
--- a/src/mod/codecs/mod_codec2/mod_codec2.c
+++ b/src/mod/codecs/mod_codec2/mod_codec2.c
@@ -30,7 +30,7 @@
*/
#include
-#include
+#include
/* Uncomment to log input/output data for debugging
#define LOG_DATA
diff --git a/w32/download_libcodec2.props b/w32/download_libcodec2.props
index d045576fb5..f46c97437c 100644
--- a/w32/download_libcodec2.props
+++ b/w32/download_libcodec2.props
@@ -34,6 +34,7 @@
outputfolder=""
outputfilename=""
extractto="$(BaseDir)libs\"
+ moveafter="libcodec2-$(libcodec2_Version)\src|libcodec2-$(libcodec2_Version)\codec2"
/>
diff --git a/w32/libcodec2.props b/w32/libcodec2.props
index bb670ca61b..6b3d7564e6 100644
--- a/w32/libcodec2.props
+++ b/w32/libcodec2.props
@@ -8,7 +8,7 @@
- $(libcodec2LibDir)\src;%(AdditionalIncludeDirectories)
+ $(libcodec2LibDir);%(AdditionalIncludeDirectories)
\ No newline at end of file