I'm trying to use the PocketSphinx speech to text library in my project as a Git submodule. So, I added the submodule to my dependency folder and I added the following code to my MakeFile:
add_subdirectory(dependencies/pocketsphinx)
But, when I'm building the project, I'm getting an error saying that:
[build] /home/aniket/code/restapi/dependencies/pocketsphinx/src/allphone_search.c:43:10: fatal error: pocketsphinx.h: No such file or directory
[build] 43 | #include <pocketsphinx.h>
[build] | ^~~~~~~~~~~~~~~~
[build] compilation terminated.
My guess is that CMAKE cannot find the header files; but, when I build PocketSphinx alone it works fine.
I'm also using the JsonCpp library, which compiles without any problem.
My CMAKE file is:
cmake_minimum_required(VERSION 3.2.0)
project(assistant)
add_executable(${PROJECT_NAME} src/main.cpp)
add_subdirectory(dependencies/jsonpp)
add_subdirectory(dependencies/pocketsphinx)
target_include_directories(${PROJECT_NAME} PUBLIC include PUBLIC
dependencies/jsonpp/include)
target_include_directories(${PROJECT_NAME} PRIVATE include
PRIVATE dependencies/jsonpp/include)
target_link_directories(${PROJECT_NAME} PRIVATE build/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncpp curl)
Here's my directory structure:
.
├── build
├── dependencies
│ ├── jsonpp
│ │ ├── cmake
│ │ ├── devtools
│ │ ├── doc
│ │ ├── example
│ │ ├── include
│ │ ├── pkg-config
│ │ ├── src
│ │ └── test
│ └── pocketsphinx
│ ├── cython
│ ├── docs
│ ├── doxygen
│ ├── examples
│ ├── gst
│ ├── include
│ ├── model
│ ├── programs
│ ├── src
│ └── test
├── include
└── src
I have a project that has multiple subdirectories and I have a unit testing framework (UnitTest++) in the following folder structure:
root_dir
├── sub_dir1
│ ├── main.cpp
│ ├── some_class.hpp
│ └── test.cpp
├── sub_dir2
│ ├── another_class.hpp
│ ├── main.cpp
│ └── test.cpp
├── UnitTest++
│ ├── libUnitTest++.a
└── makefile
I plan to have more sub_dir# in the future.
How do I use make in the root directory so that it would compile all the subdirectories?
How can I do it in a good practice. This is the repo structure:
~/workspace$ tree -L 3
.
├── my_program
│ ├── src
│ │ ├── module1
│ │ ├── module2
│ │ ├── CMakeLists.txt
│ │ └── ...
├── needed_library
│ ├── src
│ │ ├── module3
│ │ ├── module4
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ └── ...
For needed_library, I learned from the README that I can build it manually by:
mkdir build
cd build
cmake ../src
make
make install
And needed library and headers will be installed.
How can I integrate this process into my own program's CMakelists.txt? And link the desired library and header to my program?
I usually have plain python objects in my Django project that have specific responsabilities like observers, strategy objects, factories, etc. Where should I place those for a more organized file structure? There is a pattern in the industry for that?
There's nothing like an "industry standard" here. Django does have some expectations about django-specific stuff (models, custom template tags and filters, management commands etc) and a couple conventions (the views and urls modules for example - you can technically name them however you want, but everyone expects them to be named "views" and "urls"), but everything else is just plain python code and can be organized however it makes sense to you. The only recommandations here are the obvious ones - high cohesion, low coupling, etc...
I can't comment on how widely this is adopted or if it is the right way, personally I follow the project structure outlined in the Two Scoops of Django book. A similar setup is outlined here https://django-project-skeleton.readthedocs.io/en/latest/structure.html as such:
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README
If I want to create objects and functions accessible to all apps I create a utils module at the app level. If I am creating utility functions and objects specific to an app I place the utils module in the app directory. Just personal preference really.
Hope it helps.
I'm fairly new to webpack and I'm trying to understand what's the proper way to include my assets folder into the dist folder using webpack (or one of its plugins).
This is the structure of my project:
├── package.json
├── webpack.config.js
├── src
│ ├── index.html
│ ├── app.js
│ ├── components
│ │ ├── ...
│ ├── assets
│ │ ├── factory.png
│ │ ├── factory_white.png
I managed to solve my own issue by reading around about copy-webpack-plugin